Flashii Docs

(旧Railgun) if it ain't broke, we'll break it

User Tools

Site Tools


senses:packages:kmj-json

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
senses:packages:kmj-json [2025/07/28 01:20] – created flashsenses:packages:kmj-json [2026/04/27 00:21] (current) – removed lie flash
Line 2: Line 2:
  
 The kmj-json package provides a JSON codec. The kmj-json package provides a JSON codec.
- 
-The runtime provides this library through the [[https://www.lua.org/manual/5.4/manual.html#luaL_newlib|luaL_newlib]] auxiliary library function, so all fields can be assumed to be functions. 
  
 ===== decode ===== ===== decode =====
Line 13: Line 11:
   decode(input: string): (output: any)   decode(input: string): (output: any)
  
-This function takes a single argument, that being the JSON encoded representation of a type, and will return a single value, that being the decoded Lua equivalent value type of the given JSON. If the input cannot be parseda Lua ''nil'' will be returned.+==== Arguments ==== 
 + 
 +  - The first argument should contain the JSON encoded representation of a type
 + 
 +==== Returns ==== 
 + 
 +  - The first return value will be the decoded Lua equivalent value type of the given JSON, or ''nil'' if the input could not be interpreted successfully.
  
 ===== encode ===== ===== encode =====
Line 23: Line 27:
   encode(input: any): (output: string|nil)   encode(input: any): (output: string|nil)
  
-This function takes a single argument, that being the Lua value that is intended to be converted to a JSON encoded string, and a single return value containing the JSON encoded representation of the given inputIf the input cannot be understood, ''nil'' will be returned. Of the eight basic Lua types//nil//, //boolean//, //number//, //string// and //table// are supported.+==== Arguments ==== 
 + 
 +  - The first argument should contain the Lua value that should be JSON encoded. Accepted Lua types are //nil//, //boolean//, //number//, //string// and //table//. 
 + 
 +==== Returns ==== 
 + 
 +  - The first return value will be the JSON encoded representation of the given input, or a Lua ''nil'' if an unsupported value such as //function//, //userdata// or //thread// was given. 
senses/packages/kmj-json.1753665649.txt.gz · Last modified: by flash