json functions
Function to parse json strings
Description
json_int( const json[], const token[], &result )
json_float( const json[], const token[], &Float:result )
json_str( const json[], const token[], result[], maxlen )
Search the json string for the token, and set the result with the value of the token.
Parameters
json | json-formatted string |
token | token, dot-separated if hierachical |
result | variable to be set to the found value/string |
maxlen | max size of the result buffer |
These functions parse a json string, finds the given token, and returns the value
Return value
Returns 1 if the token was found. 0 if not found.
The result parameter is set to the value/string.
Example usage
new json{} = "{\"myobject\":{\"first\":100, \"second\":200, \"an_array\":[11, 22, 33, 44]}}"; new x, r; x = json_int( json, "myobject.an_array[2]", r ); // x = 1, r = 33 x = json_int( json, "myobject.second", r ); // x = 1, r = 200 x = json_int( json, "first", r ); // x = 0