Difference between revisions of "LlJsonGetValue"

From Second Life Wiki
Jump to navigation Jump to search
m (first example is a reasonable redirect)
m (basic syntax examples of the list parameter and the results it might cause)
Line 9: Line 9:
|constants
|constants
|examples=
|examples=
 
<lsl>
string j;
j=llJsonGetValue(j,[]); //returns the whole "list" of a JSON. It might just be one entry or a whole nested list or whole nested object.
//if "j" is a single JSON_STRING, this may return what the string represents as a JSON within a string; a JSON_NUMBER , JSON_TRUE ...
j=llJsonGetValue(j,[1]);              //returns only the first  entry. An entry can be many things, a string, a float stored as string,
                                      //a [list] or {object}, each entry being separated by a comma from other entries.
                                      //list and object entries may contain multiple comma separated entries within them.
j=              llJsonGetValue(j,[2]);//returns only the second entry... (all the above still counts)
j=llJsonGetValue(llJsonGetValue(j,[2]),[3]);//returns the third SUB-ENTRY of the JSON_LIST that IS the second entry, (otherwise returns JSON_INVALID)
</lsl>
see [[LlJsonValueType]] for LlJsonGetValue()-examples, because its better to test if the LlJsonValueType() is correct before getting its value as that type.
see [[LlJsonValueType]] for LlJsonGetValue()-examples, because its better to test if the LlJsonValueType() is correct before getting its value as that type.



Revision as of 17:52, 10 September 2014

Summary

Function: string llJsonGetValue( string json, list specifiers );
0.0 Forced Delay
10.0 Energy

Gets the value indicated by specifiers from the json string.
Returns a string made by parsing json, a string representing json and traversing as specified by specifiers.

• string json
• list specifiers

When the input is invalid or no result can be found this function returns JSON_INVALID. If the result is null the function returns JSON_NULL.

Specification

Examples

<lsl> string j; j=llJsonGetValue(j,[]); //returns the whole "list" of a JSON. It might just be one entry or a whole nested list or whole nested object. //if "j" is a single JSON_STRING, this may return what the string represents as a JSON within a string; a JSON_NUMBER , JSON_TRUE ... j=llJsonGetValue(j,[1]); //returns only the first entry. An entry can be many things, a string, a float stored as string,

                                      //a [list] or {object}, each entry being separated by a comma from other entries.
                                      //list and object entries may contain multiple comma separated entries within them.

j= llJsonGetValue(j,[2]);//returns only the second entry... (all the above still counts) j=llJsonGetValue(llJsonGetValue(j,[2]),[3]);//returns the third SUB-ENTRY of the JSON_LIST that IS the second entry, (otherwise returns JSON_INVALID) </lsl>

see LlJsonValueType for LlJsonGetValue()-examples, because its better to test if the LlJsonValueType() is correct before getting its value as that type.

See Also

Functions

•  llList2Json
•  llJson2List
•  llJsonSetValue
•  llJsonValueType

Articles

•  Typecast

Deep Notes

History

Date of Release 20/05/2013

Signature

function string llJsonGetValue( string json, list specifiers );