Difference between revisions of "LlJson2List"
Jump to navigation
Jump to search
m (added date of release) |
(+1 barely useful example, except to compress json string size a little bit) |
||
Line 12: | Line 12: | ||
|constants | |constants | ||
|examples= | |examples= | ||
<lsl> | |||
string Json2CSV(string csv){ | |||
list li llJson2List(li); | |||
return llList2CSV(Li); | |||
}//This function converts a Json ARRAY into a string of comma separated values, basically just removing all the ". This makes it easier to read. | |||
//If the json contains a nested array like "[[1,2],[3,4]]", the returned csv string will be : "[1,2],[3,4]"//not a nicely readable CSV, but a shorter string that will save some memory. | |||
</lsl> | |||
|helpers | |helpers | ||
|also_functions={{LSL DefineRow||[[llList2Json]]|}} | |also_functions={{LSL DefineRow||[[llList2Json]]|}} |
Revision as of 03:27, 15 September 2014
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: list llJson2List( string src );0.0 | Forced Delay |
10.0 | Energy |
This function takes a string representing JSON, and returns a list of the top level.
Returns a list made by parsing src, a string representing json.
• string | src |
To convert a list into a json formatted string use llList2Json.
Specification
- If the json represents a single item (number, string, true, false or null) then a list with 1 item will be returned.
- If the json represents an object then a strided list of key, value pairs is returned. All values that are objects or arrays are returned as json strings.
- If the json represents an array then a list of all items is returned. All values that are objects or arrays are returned as json strings.
Examples
<lsl> string Json2CSV(string csv){
list li llJson2List(li); return llList2CSV(Li);
}//This function converts a Json ARRAY into a string of comma separated values, basically just removing all the ". This makes it easier to read. //If the json contains a nested array like "[[1,2],[3,4]]", the returned csv string will be : "[1,2],[3,4]"//not a nicely readable CSV, but a shorter string that will save some memory.
</lsl>