pebxcvi's picture
big update
d7bb13e
raw
history blame
2.57 kB
1.36 Json .292
1.36.1 Json.Decode .292
1.36.2 Json.DecodeFromString .293
1.36.3 Json.Encode .293
Json
Json. Decode
Brief
Decode a JSON structure (held in a memory container) into a table.
Definition
Json.Decode( MemoryContainer in, number offset = -1, size = -1 )
Arguments
in - The memory container holding the JSON-formatted block.offset - Offset into the container where the JSON structure begins.size - The size of
the JSON structure.
Return Values
A table containing the decoded data structure, or a negative number on error.
-1 - Invalid argument.
-2 - Parse error.
Description
This function parses a JSON-formatted data structure held in the provided memory container, and returns a corresponding Lua table. Arrays will
be treated as key-value pairs with the array index as the key (the base index will be 1).
Examples
container = MemoryContainer.Create ( 1024 )
See Also
� Json.DecodeFromString
� Json. Encode
Json.DecodeFromString
Brief
Decode a JSON structure (held in a string) into a table.
Definition
Json.DecodeFromString( string in )
Arguments
in - A string holding a JSON-formatted data structure.
Return Values
A table containing the decoded data structure, or a negative number on error.
-1 - Invalid argument.
-2 - Parse error.
Description
This function parses a JSON-formatted data structure and returns a corresponding Lua table. Arrays will be treated as key-value pairs with the
array index as the key (the base index will be 1).
Examples
decoded = Json.DecodeFromString(
"{\"session\":{\"@expires\":\"1314268686648V� ,\"@id\":\"3a50cfb2\",\"person\":{\"@id\":\"e8a41543\",\"di^
)
See Also
� Json.Decode
� Json. Encode
Json.Encode
Brief
Encode a table into JSON format, storing the results in the provided memory container.
Definition
number Json.Encode( MemoryContainer out, table in )
Arguments
out - The memory container to write the JSON-encoded data into.in - The table to be encoded.
Return Values
The number of bytes written to the output memory container, or a negative number on error.
-1 - Invalid argument.
-2 - Not enough space in the memory container.
-3 - Unable to encode table in the JSON format.
Description
Write out a JSON-formatted data structure representing the given table to the provided memory container. The structure of the table must conform
to the JSON specification.
Examples
testtable =
{"session":{"service":{"@id":"bb88aea9","display_name":"Testing"},"person":{"@id":"e8a41543","display_nari
= MemoryContainer.Create( 1024 )
result = Json.Encode( container, testtable )
See Also
� Json.Decode
� Json.DecodeFromString