json - json Generating and parsing libraries#
Adapted Air780E Air780EP Air780EPS Air780EQ Air700EAQ Air700EMQ Air700ECQ Air201
Note
This page document is automatically generated by this file. If there is any error, please submit issue or help modify pr, thank you!
Tip
This library has its own demo,click this link to view the demo example of json
json.encode(obj,t)#
Serialize an object to a json string
Parameters
Incoming Value Type |
Explanation |
---|---|
obj |
Objects that need to be serialized |
string |
Floating-point number precision and mode, when this does not exist, the default value is “7f”, numbers only support “0~14”, mode only supports”f/g” |
Return Value
return value type |
explanation |
---|---|
string |
the json string after serialization. if it fails, it is returned nil |
string |
error message of serialization failure |
Examples
json.encode(obj)-->Floating-point numbers are converted to strings using%.7g.
json.encode(obj,"12f")-->Floating point numbers are converted to strings using%.12f
-- 2024.1.9 Since then, 7f is used by default to format floating point numbers.
-- Previous versions used 7g to format floating numbers
json.decode(str)#
Deserialize a string into an object
Parameters
Incoming Value Type |
Explanation |
---|---|
string |
The json string that needs to be deserialized. |
Return Value
return value type |
explanation |
---|---|
obj |
The deserialized object (usually a table), which is returned if it fails.nil |
result |
Returns 1 on success, otherwise 0 |
err |
Error message of deserialization failure |
Examples
json.decode("[1,2,3,4,5,6]")