|LSL Portal||Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials|
This function takes a list and returns a JSON string of that list as either a json object or json array.
Returns a string that is either values serialized as a JSON type, or if an error was encountered JSON_INVALID.
To convert a json formatted string into a list use llJson2List.
- If type is JSON_OBJECT the list must be a strided list of key, value pairs and a string representing a json object will be returned.
- If type is JSON_ARRAY then a string representing a json array will be returned.
- If type is any other string then JSON_INVALID will be returned.
- Json types from the input list are inferred from the LSL data type
- integer and float types are encoded as JSON_NUMBER
- "true" and "false" are encoded as JSON_TRUE and JSON_FALSE, respectively
- "null" is encoded as JSON_NULL
- properly-formatted json strings in the input are kept as-is (will either be JSON_STRING, JSON_OBJECT, or JSON_ARRAY)
- all other strings encoded as JSON_STRING
- Note in particular that strings containing valid JSON numbers are converted to JSON strings, not left as JSON numbers (llJsonSetValue gives to strings that contain JSON numbers, which leaves them as numbers. ). This differs to the treatment that
|Type Flags||Value||Unicode||URL Encoded||HTML Encoded||Description|
|JSON_INVALID||||"%EF%B7%90"||||Value returned when inputs are not well formed.|
- Note that string values items are interpreted as JSON, not LSL, strings. Quotation marks, if required, must be added explicitly. For example,
llJson2List(llList2Json(JSON_ARRAY, ["bacon", "true", "false", "null"]))returns the LSL list
["bacon", JSON_TRUE, JSON_FALSE, JSON_NULL], while
llJson2List(llList2Json(JSON_ARRAY, ["\"bacon\"", "\"true\"", "\"false\"", "\"null\""]))returns the LSL list
["bacon", "true", "false", "null"]