Skip to content
lsl.devlsl.devLSL Dev

LlJson2List

Looking for the current API? Open the llJson2List reference →

Wiki description

This function takes a string representing JSON, and returns a list of the top level.

Function notes

To convert a list into a json formatted string use llList2Json.

Return value notes

Returns a list made by parsing src, a string representing json.

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

default
{
    state_entry()
    {
        list items;

        string value = "89556747-24cb-43ed-920b-47caed15465f";
        items = llJson2List(value);
        // ["89556747-24cb-43ed-920b-47caed15465f"]

        string object = "{\"pi\": 3.14, \"set\": [1,2,3], \"status\": \"ok\"}";
        items = llJson2List(object);
        // ["pi", 3.140000, "set", "[1,2,3]", "status", "ok"]

        string array = "[0, 3.14, [1,2,3], {}]";
        items = llJson2List(array);
        // [0, 3.140000, "[1,2,3]", "{}"]
    }
}

See also: functions

See also: articles

History

Date of Release 20/05/2013
Original wiki source

Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.

From the Second Life Wiki

Community documentation adapted from LlJson2List, by Linden Research, Inc. and contributing residents.View contributors and history.

Imported wiki revision:

Licensed under CC BY-SA 3.0. Last wiki edit: .Formatting and links have been adapted for this site; API metadata follows the LSL definitions.