<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.secondlife.com/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Gistya+Eusebio</id>
	<title>Second Life Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.secondlife.com/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Gistya+Eusebio"/>
	<link rel="alternate" type="text/html" href="https://wiki.secondlife.com/wiki/Special:Contributions/Gistya_Eusebio"/>
	<updated>2026-06-10T02:24:44Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://wiki.secondlife.com/w/index.php?title=Talk:Json_usage_in_LSL&amp;diff=1179393</id>
		<title>Talk:Json usage in LSL</title>
		<link rel="alternate" type="text/html" href="https://wiki.secondlife.com/w/index.php?title=Talk:Json_usage_in_LSL&amp;diff=1179393"/>
		<updated>2013-06-23T14:58:09Z</updated>

		<summary type="html">&lt;p&gt;Gistya Eusebio: responding to enquotation badness&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I am concerned because the JSON format specifies at json.org that you can use escape codes like \u0000 to represent Unicode byte values in strings. But LSL has the ugly habit of censoring and altering strings so that a character with byte value of 0x0000 is removed from the string, and some functions like llSHA1String are essentially broken since they also convert UTF-16 integers between \u0128–\u0255 into UTF-8 byte values starting with %c2 (which therefore have a different integer value due to the addition of the extraneous byte). Is LSL also going to mangle JSON strings&#039; byte values when it renders them into LSL strings? Won&#039;t this corrupt attempts at efficiently verifying the signatures of any incoming messages, and thwart attempts to generate proper signatures for some outgoing JSON-formatted requests? Or do the Lindens have plans to finally give us a proper suite of escape codes in LSL (or some other solution)?&lt;br /&gt;
--[[User:Gistya Eusebio|Gistya Eusebio]] 09:41, 30 May 2013 (PDT)&lt;br /&gt;
&lt;br /&gt;
Add to that the complete crash-and-burn if your string starts with a quote, generating invalid JSON. I really don&#039;t get why LL finds it advantageous to include magic switches which forces everybody to do workaround for normal use, and ensures that all future JSON implementations in SL must be hand-coded to keep backwards compatibility with the spec breaks currently implemented.&lt;br /&gt;
[[User:Tali Rosca|Tali Rosca]] 15:50, 19 June 2013 (PDT)&lt;br /&gt;
&lt;br /&gt;
:This sounds like a bug, you should report it. -- &#039;&#039;&#039;[[User:Strife_Onizuka|Strife]]&#039;&#039;&#039; &amp;lt;sup&amp;gt;&amp;lt;small&amp;gt;([[User talk:Strife_Onizuka|talk]]|[[Special:Contributions/Strife_Onizuka|contribs]])&amp;lt;/small&amp;gt;&amp;lt;/sup&amp;gt; 21:49, 20 June 2013 (PDT)&lt;br /&gt;
&lt;br /&gt;
::nm I see that you did. {{jira|BUG-2594}} -- &#039;&#039;&#039;[[User:Strife_Onizuka|Strife]]&#039;&#039;&#039; &amp;lt;sup&amp;gt;&amp;lt;small&amp;gt;([[User talk:Strife_Onizuka|talk]]|[[Special:Contributions/Strife_Onizuka|contribs]])&amp;lt;/small&amp;gt;&amp;lt;/sup&amp;gt; 21:50, 20 June 2013 (PDT)&lt;br /&gt;
&lt;br /&gt;
:::I&#039;ve been kicking and screaming about getting a robust JSON handling :-) 2594 got us some way, but we still have {{jira|BUG-2736}}, which I consider so exceedingly ill-advised as to be a bug, despite the insistence that it&#039;s a really awesome feature. [[User:Tali Rosca|Tali Rosca]] 16:39, 21 June 2013 (PDT)&lt;br /&gt;
&lt;br /&gt;
::::&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;The trailing quotation mark is the real nasty problem, not the leading one :D But yeah.. if they do add the capability to handle enquoted* text, how would that break anyone&#039;s scripts? Is anyone really relying on enquotation to invalidate their JSON strings on purpose? Besides when has breaking people&#039;s scripts stopped them from doing anything? I have tens of thousands of L$ worth of vehicles that are now worthless due to the Havok 4 update, but hey, life goes on. My copy of Microsoft Word 1.0 for Mac won&#039;t run on Mountain Lion either. I like backwards compatibility but we developers would be out of a job if software never had to be rewritten to work with the ever-evolving platforms that are out there :D &amp;lt;br&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;--[[User:Gistya Eusebio|Gistya Eusebio]] 07:58, 23 June 2013 (PDT) &amp;lt;br&amp;gt;* I know &amp;quot;enquoted&amp;quot; is not in the dictionary. However it is in the lexicon. :D&lt;/div&gt;</summary>
		<author><name>Gistya Eusebio</name></author>
	</entry>
	<entry>
		<id>https://wiki.secondlife.com/w/index.php?title=Json_usage_in_LSL&amp;diff=1179392</id>
		<title>Json usage in LSL</title>
		<link rel="alternate" type="text/html" href="https://wiki.secondlife.com/w/index.php?title=Json_usage_in_LSL&amp;diff=1179392"/>
		<updated>2013-06-23T14:19:44Z</updated>

		<summary type="html">&lt;p&gt;Gistya Eusebio: enhancing the warning about how multiple members with the same name are handled&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{LSL Header|lm=*}}{{LSLC|}}{{LSLC|JSON|*Json usage in LSL}}&lt;br /&gt;
==Type Conversions==&lt;br /&gt;
&lt;br /&gt;
Json has native representation for:&lt;br /&gt;
* numbers - directly mappable to LSL Integer and Float (json numbers without a decimal point are assumed to be Integers, those with a decimal point are Floats)&lt;br /&gt;
* strings - identical to LSL [[String]]&lt;br /&gt;
* arrays - a list of values of any type: directly analogous to an LSL [[List]]&lt;br /&gt;
* objects - represented in LSL as a strided list of name/value pairs (see below re: values)&lt;br /&gt;
* the constants &#039;true&#039; and &#039;false&#039; - directly mapped to and from the LSL constants [[JSON_TRUE]] and [[JSON_FALSE]]&lt;br /&gt;
* the constant &#039;null&#039; - directly mapped to and from the LSL constant [[JSON_NULL]]&lt;br /&gt;
* All other LSL types (Key, Rotation, and Vector) are implicitly converted to their string representation when converting to Json; when converting from Json to LSL, these values are returned as String values, so the script must explicitly convert using the existing conversion methods.&lt;br /&gt;
&lt;br /&gt;
==New LSL Methods==&lt;br /&gt;
===Specifying Json Elements===&lt;br /&gt;
&lt;br /&gt;
[[llJsonGetValue]], [[llJsonValueType]] and [[llJsonSetValue]] each take the same first two arguments:&lt;br /&gt;
  1. a JSON value in the form of a [[String|string]], and   &lt;br /&gt;
  2. a set of specifiers in the form of a [[List|list]].&lt;br /&gt;
[[llJsonSetValue]] additionally takes a third an argument: &lt;br /&gt;
  3. a JSON value in the form of a [[String|string]]. &lt;br /&gt;
&lt;br /&gt;
To understand specifiers one must generally understand that JSON data is structured in a [http://en.wikipedia.org/wiki/Nested_set_model nested set model]. LSL&#039;s built-in JSON parser uses the supplied &amp;quot;specifiers&amp;quot; list to perform [http://en.wikipedia.org/wiki/Tree_traversal tree traversal] on the nodes of the supplied JSON [http://en.wikipedia.org/wiki/Tree_(data_structure) tree data structure]. A JSON tree may be visualized as a set of hierarchical levels of parents and children. Each level is contained within &#039;&#039;&#039;curly braces {for objects, which are lists of members, that are defined as key-value pairs}&#039;&#039;&#039; or &#039;&#039;&#039;square braces [for arrays of elements, that are defined as single values]&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
When JSON is presented in human-readable form, it is traditionally formatted such that the first parent level of organization is indented farthest to the left, and each more deeply-nested child level of organization is indented farther and farther to the right. The left-most level of nodes have no parents, only children. They begin with the very first member that appears after the initial &amp;quot;{&amp;quot; character of the JSON string (if it starts as an object), or the first element that appears after the initial &amp;quot;[&amp;quot; character (if it starts as an array). A node is considered as being a parent only if it has a non-null JSON object or array as its value.&lt;br /&gt;
&lt;br /&gt;
With that parent-child tree data structure in mind, the specifiers list that you supply in the above functions tell LSL&#039;s JSON parser how to [http://en.wikipedia.org/wiki/Tree_(data_structure)#Traversal_methods walk the tree] of the JSON data that you have supplied with the first argument of the function. The first specifier in the list tells the LSL JSON parser which node to walk to first. The next specifier tells it which of that node&#039;s children to walk to. Once the LSL parser has &amp;quot;walked&amp;quot; to the last destination node specified by your list of specifiers, it will then perform the function on the JSON value that it finds there. &lt;br /&gt;
&lt;br /&gt;
If, anywhere along the line, any of the specified nodes do not exist, [[llJsonGetValue]] and [[llJsonValueType]] will almost always return [[JSON_INVALID]]. However there is a rare exception: if any specifier in the list leads to a node that has no characters in its JSON string value, JSON_NULL will be returned instead of JSON_INVALID—no matter what might come after it in the specifiers list. For example in:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
string parent = &amp;quot;{\&amp;quot;parent\&amp;quot;:,}&amp;quot;; &lt;br /&gt;
string test1 = llJsonGetValue(example,[parent]);&lt;br /&gt;
string test2 = llJsonGetValue(example,[&amp;quot;parent&amp;quot;,&amp;quot;child that doesn&#039;t exist&amp;quot;,&amp;quot;etc.&amp;quot;]);&lt;br /&gt;
&amp;lt;/lsl&amp;gt; &lt;br /&gt;
test1 and test2 will both be JSON_NULL. &lt;br /&gt;
&lt;br /&gt;
The same is true for arrays: a specifier pointing to any element of a valid array will return JSON_NULL anywhere there is no JSON value specified at given position in the array:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
string &amp;quot;{\&amp;quot;parent\&amp;quot;:[ , ,  , , ]}&amp;quot;;&lt;br /&gt;
string test1 = llJsonGetValue(example,[&amp;quot;parent&amp;quot;,2]);&lt;br /&gt;
string test2 = llJsonGetValue(example,[&amp;quot;parent&amp;quot;,1,&amp;quot;child that does not exist&amp;quot;,&amp;quot;etc.&amp;quot;]);&lt;br /&gt;
&amp;lt;/lsl&amp;gt;&lt;br /&gt;
test1 and test2 will also both be JSON_NULL. &lt;br /&gt;
&lt;br /&gt;
These types of scenarios may be useful in determining valid JSON paths for the setter: in all the scenarios where JSON_NULL is returned, the same set of specifiers is able to be successfully used for [[llJsonSetValue]]. However if [[JSON_INVALID]] is returned, there is no guarantee the setter won&#039;t return an error.&lt;br /&gt;
&lt;br /&gt;
For [[llJsonGetValue]], if a JSON value is present at the specified node, it will be returned by the function. The value may an object that contains no valid JSON data, so be careful. Such an object will be deemed a [[JSON_OBJECT]] by [[llJsonValueType]], even if its contents are not valid JSON. Therefore it&#039;s always best to check the [[llJsonValueType]] of any specified value to make sure it&#039;s valid before using the information in your script. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{LSL Tip|Counter-intuitiveness warning! If there exist multiple members with the same name in the same object at the same child-level, a specifier that points to that name will be interpreted by LSL as pointing to the member closest to the end of the string! This behavior is opposite from the behavior of [[llListFindList]] and [[llSubStringIndex]], which always find the match that is closest to the beginning of the list or string, respectively!}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The specifiers list may only consist of strings/keys (for object member keys), and integers (for array element positions), which define a path to the desired value in a JSON compound object.&lt;br /&gt;
&lt;br /&gt;
* An empty list specifies the entire Json value.&lt;br /&gt;
* If the list is not empty, each element of the list is used to select the element at the same level of nesting in the JSON value:&lt;br /&gt;
** if the specifier list element is a string, then the corresponding element in the json value must be an object and the list element selects the value whose JSON name exactly matches the string.&lt;br /&gt;
** if the specifier list element is an integer, then the corresponding element in the json value must be an array and the list element is used as a zero-based index into the Json array.&lt;br /&gt;
* Additionally llJsonSetValue accepts [[JSON_APPEND]] as a specifier to indicate appending the value to the end of the array at that level. Be careful because If the value at that level is not an array, it will be overwritten and replaced with the array you&#039;re setting! &lt;br /&gt;
&lt;br /&gt;
For example, given the JSON value:&lt;br /&gt;
&amp;lt;javascript&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    alpha: 1,&lt;br /&gt;
    beta: [&lt;br /&gt;
       &amp;quot;x&amp;quot;,&lt;br /&gt;
       &amp;quot;y&amp;quot;,&lt;br /&gt;
       &amp;quot;z&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    gamma: {&lt;br /&gt;
       &amp;quot;a&amp;quot;: 3.2,&lt;br /&gt;
       &amp;quot;b&amp;quot;: true&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/javascript&amp;gt;&lt;br /&gt;
the contents of the string returned would be:&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;alpha&amp;quot; ] )        ⇒    1&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;beta&amp;quot; ] )         ⇒    [ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ]&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;beta&amp;quot;, 2 ] )      ⇒    z&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;gamma&amp;quot;, &amp;quot;a&amp;quot; ] )   ⇒    3.2&lt;br /&gt;
&amp;lt;/lsl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
llJsonSetValue(string json, list specifiers, string value_to_set) will force the resulting JSON to conform with the specifiers supplied, as long as the specified path is traversable.&lt;br /&gt;
&lt;br /&gt;
==Json Interrogation and Validation==&lt;br /&gt;
&lt;br /&gt;
To determine the type of a json value:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;lsl&amp;gt;string type = llJsonValueType( string json, list specifiers );&amp;lt;/lsl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:returns one of several following special constants (see table below). Each constant has a name, JSON_XXXX, which unlike most LSL constants is not an integer—instead, it&#039;s a single-character string. The single character is not printable but has a specific escape value (if run through llEscapeURL) in the range of  %EF%B7%90–97. The below table shows each constant&#039;s invocation and escape code:&lt;br /&gt;
&lt;br /&gt;
{{LSL Constants/JSON}}&lt;br /&gt;
&lt;br /&gt;
==Json to LSL Conversion==&lt;br /&gt;
&lt;br /&gt;
To directly extract a Json value to an LSL string:&lt;br /&gt;
&lt;br /&gt;
 string value = llJsonGetValue( string json, list specifiers );&lt;br /&gt;
* &#039;&#039;json&#039;&#039; is a string containing a valid json array or object value&lt;br /&gt;
* &#039;&#039;specifiers&#039;&#039; is a list of specifiers (see Specifying Json Elements)&lt;br /&gt;
* returns a json string&lt;br /&gt;
* if the specifiers do not indicate a value that exists in the input, [[JSON_INVALID]] is returned&lt;br /&gt;
&lt;br /&gt;
To convert a json compound value (either an array or an object) to an LSL List:&lt;br /&gt;
&lt;br /&gt;
 list values = llJson2List( string json );&lt;br /&gt;
* &#039;&#039;json&#039;&#039; is a string containing a valid json array or object value&lt;br /&gt;
* If the string in json is not a valid json object or array a list with a single item matching the conversion above is returned.&lt;br /&gt;
&lt;br /&gt;
==Recursive Parsing==&lt;br /&gt;
&lt;br /&gt;
Since any value in a Json array or object may be any arbitrary type, including an array or object, the parsing methods must handle nested values.  Nested arrays or objects are not converted, but remain LSL String values.  If an LSL script needs to use the components in such a nested value, it must explicitly pass that string to the appropriate method.  For example, the following json value is passed to llJson2List:&lt;br /&gt;
&amp;lt;javascript&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    alpha: 1,&lt;br /&gt;
    beta: [&lt;br /&gt;
       &amp;quot;x&amp;quot;,&lt;br /&gt;
       &amp;quot;y&amp;quot;,&lt;br /&gt;
       &amp;quot;z&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    gamma: {&lt;br /&gt;
       a: 3.2,&lt;br /&gt;
       b: true&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/javascript&amp;gt;&lt;br /&gt;
The result would be an LSL list with a stride of 2: the first elements of the 3 strides would be &amp;quot;alpha&amp;quot;, &amp;quot;beta&amp;quot;, and &amp;quot;gamma&amp;quot;.  The second element of the first stride would be the integer 1, but the second elements of the other two strides would be LSL strings containing the json representation of the array &#039;[ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ]&#039; and object &#039;{ a: 3.2, b: true }&#039; respectively.&lt;br /&gt;
&lt;br /&gt;
==LSL to Json==&lt;br /&gt;
&lt;br /&gt;
To convert a list to json:&lt;br /&gt;
 string json = llList2Json( string type, list values );&lt;br /&gt;
* &#039;&#039;type&#039;&#039; must be either [[JSON_ARRAY]] or [[JSON_OBJECT]]&lt;br /&gt;
* &#039;&#039;values&#039;&#039; is the list to be converted to json.&lt;br /&gt;
&lt;br /&gt;
:Produces an LSL String containing a Json compound value, either an array or an object depending on type, containing the values in the input list.  &lt;br /&gt;
&lt;br /&gt;
:If type is [[JSON_ARRAY]], the list may contain values of any LSL type; they are converted as described in Type Conversions above.  &lt;br /&gt;
&lt;br /&gt;
:If type is [[JSON_OBJECT]], the list must have a stride of 2.  The first value of each stride must be a string.  The second value of each stride may be any LSL type, and are converted as described in Type Conversions above. [[JSON_INVALID]] is returned if the stride is not 2.&lt;br /&gt;
&lt;br /&gt;
:[[JSON_INVALID]] is returned if any other string or json type is specified as the type.&lt;br /&gt;
&lt;br /&gt;
To directly set a Json value within a string:&lt;br /&gt;
&lt;br /&gt;
 string jsonresult = llJsonSetValue( string json, list specifiers, string value );&lt;br /&gt;
* &#039;&#039;json&#039;&#039; is a string containing a valid json array or object value&lt;br /&gt;
* &#039;&#039;specifiers&#039;&#039; is a list of specifiers (see [[#Specifying Json Elements]])&lt;br /&gt;
* &#039;&#039;value&#039;&#039; the value to be inserted into the specified place in json&lt;br /&gt;
* Returns the newly modified json string&lt;br /&gt;
&lt;br /&gt;
:The only failure mode for llJsonSetValue is if an array index is specified in specifiers that is negative (but not [[JSON_APPEND]]) or more greater than the list size. In all other cases the json is modified so that the set can succeed. For example if an integer is specified for a level that is an object, the object will be removed completely and replaced with an array. If the object key does not exist it will be added, and JSON_APPEND or an index one larger than the last item in an array can be used to append to an array. These features are to allow building a Json string with llJsonSetValue.&lt;br /&gt;
&lt;br /&gt;
==Recursive Construction of Compound Json Values==&lt;br /&gt;
&lt;br /&gt;
Since LSL does not support nested lists, the construction method may only be used to convert a single level; to create a Json array or object whose values are nested arrays or objects, the LSL script must first construct the nested values and then pass those values as strings to another construction method call.  For example, to construct the Json value:&lt;br /&gt;
&amp;lt;javascript&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    alpha: 1,&lt;br /&gt;
    beta: [&lt;br /&gt;
       &amp;quot;x&amp;quot;,&lt;br /&gt;
       &amp;quot;y&amp;quot;,&lt;br /&gt;
       &amp;quot;z&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    gamma: {&lt;br /&gt;
       a: 3.2,&lt;br /&gt;
       b: true&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/javascript&amp;gt;&lt;br /&gt;
The following sequence could be used:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
string gamma_value = llList2Json( JSON_OBJECT, [ &amp;quot;a&amp;quot;, 3.2, &amp;quot;b&amp;quot;, TRUE ] );&lt;br /&gt;
string beta_value  = llList2Json( JSON_ARRAY, [ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ] );&lt;br /&gt;
string value       = llList2Json( JSON_OBJECT,[ &amp;quot;alpha&amp;quot;, 1, &amp;quot;beta&amp;quot;, beta_value, &amp;quot;gamma&amp;quot;, gamma_value ] );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or the equivalent without the intermediate variables:&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
string value =&lt;br /&gt;
    llList2Json( JSON_OBJECT,&lt;br /&gt;
        [&amp;quot;alpha&amp;quot;, 1,&lt;br /&gt;
         &amp;quot;beta&amp;quot;, llList2Json( JSON_ARRAY, [ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ] ),&lt;br /&gt;
         &amp;quot;gamma&amp;quot;, llList2Json( JSON_OBJECT, [ &amp;quot;a&amp;quot;, 3.2, &amp;quot;b&amp;quot;, TRUE ] )]&lt;br /&gt;
    );&lt;br /&gt;
&amp;lt;/lsl&amp;gt;&lt;/div&gt;</summary>
		<author><name>Gistya Eusebio</name></author>
	</entry>
	<entry>
		<id>https://wiki.secondlife.com/w/index.php?title=Json_usage_in_LSL&amp;diff=1179391</id>
		<title>Json usage in LSL</title>
		<link rel="alternate" type="text/html" href="https://wiki.secondlife.com/w/index.php?title=Json_usage_in_LSL&amp;diff=1179391"/>
		<updated>2013-06-23T14:10:02Z</updated>

		<summary type="html">&lt;p&gt;Gistya Eusebio: adding note about how it picks from multiple members of the same name&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{LSL Header|lm=*}}{{LSLC|}}{{LSLC|JSON|*Json usage in LSL}}&lt;br /&gt;
==Type Conversions==&lt;br /&gt;
&lt;br /&gt;
Json has native representation for:&lt;br /&gt;
* numbers - directly mappable to LSL Integer and Float (json numbers without a decimal point are assumed to be Integers, those with a decimal point are Floats)&lt;br /&gt;
* strings - identical to LSL [[String]]&lt;br /&gt;
* arrays - a list of values of any type: directly analogous to an LSL [[List]]&lt;br /&gt;
* objects - represented in LSL as a strided list of name/value pairs (see below re: values)&lt;br /&gt;
* the constants &#039;true&#039; and &#039;false&#039; - directly mapped to and from the LSL constants [[JSON_TRUE]] and [[JSON_FALSE]]&lt;br /&gt;
* the constant &#039;null&#039; - directly mapped to and from the LSL constant [[JSON_NULL]]&lt;br /&gt;
* All other LSL types (Key, Rotation, and Vector) are implicitly converted to their string representation when converting to Json; when converting from Json to LSL, these values are returned as String values, so the script must explicitly convert using the existing conversion methods.&lt;br /&gt;
&lt;br /&gt;
==New LSL Methods==&lt;br /&gt;
===Specifying Json Elements===&lt;br /&gt;
&lt;br /&gt;
[[llJsonGetValue]], [[llJsonValueType]] and [[llJsonSetValue]] each take the same first two arguments:&lt;br /&gt;
  1. a JSON value in the form of a [[String|string]], and   &lt;br /&gt;
  2. a set of specifiers in the form of a [[List|list]].&lt;br /&gt;
[[llJsonSetValue]] additionally takes a third an argument: &lt;br /&gt;
  3. a JSON value in the form of a [[String|string]]. &lt;br /&gt;
&lt;br /&gt;
To understand specifiers one must generally understand that JSON data is structured in a [http://en.wikipedia.org/wiki/Nested_set_model nested set model]. LSL&#039;s built-in JSON parser uses the supplied &amp;quot;specifiers&amp;quot; list to perform [http://en.wikipedia.org/wiki/Tree_traversal tree traversal] on the nodes of the supplied JSON [http://en.wikipedia.org/wiki/Tree_(data_structure) tree data structure]. A JSON tree may be visualized as a set of hierarchical levels of parents and children. Each level is contained within &#039;&#039;&#039;curly braces {for objects, which are lists of members, that are defined as key-value pairs}&#039;&#039;&#039; or &#039;&#039;&#039;square braces [for arrays of elements, that are defined as single values]&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
When JSON is presented in human-readable form, it is traditionally formatted such that the first parent level of organization is indented farthest to the left, and each more deeply-nested child level of organization is indented farther and farther to the right. The left-most level of nodes have no parents, only children. They begin with the very first member that appears after the initial &amp;quot;{&amp;quot; character of the JSON string (if it starts as an object), or the first element that appears after the initial &amp;quot;[&amp;quot; character (if it starts as an array). A node is considered as being a parent only if it has a non-null JSON object or array as its value.&lt;br /&gt;
&lt;br /&gt;
With that parent-child tree data structure in mind, the specifiers list that you supply in the above functions tell LSL&#039;s JSON parser how to [http://en.wikipedia.org/wiki/Tree_(data_structure)#Traversal_methods walk the tree] of the JSON data that you have supplied with the first argument of the function. The first specifier in the list tells the LSL JSON parser which node to walk to first. The next specifier tells it which of that node&#039;s children to walk to. Once the LSL parser has &amp;quot;walked&amp;quot; to the last destination node specified by your list of specifiers, it will then perform the function on the JSON value that it finds there. &lt;br /&gt;
&lt;br /&gt;
If, anywhere along the line, any of the specified nodes do not exist, [[llJsonGetValue]] and [[llJsonValueType]] will almost always return [[JSON_INVALID]]. However there is a rare exception: if any specifier in the list leads to a node that has no characters in its JSON string value, JSON_NULL will be returned instead of JSON_INVALID—no matter what might come after it in the specifiers list. For example in:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
string parent = &amp;quot;{\&amp;quot;parent\&amp;quot;:,}&amp;quot;; &lt;br /&gt;
string test1 = llJsonGetValue(example,[parent]);&lt;br /&gt;
string test2 = llJsonGetValue(example,[&amp;quot;parent&amp;quot;,&amp;quot;child that doesn&#039;t exist&amp;quot;,&amp;quot;etc.&amp;quot;]);&lt;br /&gt;
&amp;lt;/lsl&amp;gt; &lt;br /&gt;
test1 and test2 will both be JSON_NULL. &lt;br /&gt;
&lt;br /&gt;
The same is true for arrays: a specifier pointing to any element of a valid array will return JSON_NULL anywhere there is no JSON value specified at given position in the array:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
string &amp;quot;{\&amp;quot;parent\&amp;quot;:[ , ,  , , ]}&amp;quot;;&lt;br /&gt;
string test1 = llJsonGetValue(example,[&amp;quot;parent&amp;quot;,2]);&lt;br /&gt;
string test2 = llJsonGetValue(example,[&amp;quot;parent&amp;quot;,1,&amp;quot;child that does not exist&amp;quot;,&amp;quot;etc.&amp;quot;]);&lt;br /&gt;
&amp;lt;/lsl&amp;gt;&lt;br /&gt;
test1 and test2 will also both be JSON_NULL. &lt;br /&gt;
&lt;br /&gt;
These types of scenarios may be useful in determining valid JSON paths for the setter: in all the scenarios where JSON_NULL is returned, the same set of specifiers is able to be successfully used for [[llJsonSetValue]]. However if [[JSON_INVALID]] is returned, there is no guarantee the setter won&#039;t return an error.&lt;br /&gt;
&lt;br /&gt;
For [[llJsonGetValue]], if a JSON value is present at the specified node, it will be returned by the function. The value may an object that contains no valid JSON data, so be careful. Such an object will be deemed a [[JSON_OBJECT]] by [[llJsonValueType]], even if its contents are not valid JSON. Therefore it&#039;s always best to check the [[llJsonValueType]] of any specified value to make sure it&#039;s valid before using the information in your script. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{LSL Tip|NOTE: if multiple members of the same name exist in the object, the function will return the value for the member closest to the end of the string!}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The specifiers list may only consist of strings/keys (for object member keys), and integers (for array element positions), which define a path to the desired value in a JSON compound object.&lt;br /&gt;
&lt;br /&gt;
* An empty list specifies the entire Json value.&lt;br /&gt;
* If the list is not empty, each element of the list is used to select the element at the same level of nesting in the JSON value:&lt;br /&gt;
** if the specifier list element is a string, then the corresponding element in the json value must be an object and the list element selects the value whose JSON name exactly matches the string.&lt;br /&gt;
** if the specifier list element is an integer, then the corresponding element in the json value must be an array and the list element is used as a zero-based index into the Json array.&lt;br /&gt;
* Additionally llJsonSetValue accepts [[JSON_APPEND]] as a specifier to indicate appending the value to the end of the array at that level. Be careful because If the value at that level is not an array, it will be overwritten and replaced with the array you&#039;re setting! &lt;br /&gt;
&lt;br /&gt;
For example, given the JSON value:&lt;br /&gt;
&amp;lt;javascript&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    alpha: 1,&lt;br /&gt;
    beta: [&lt;br /&gt;
       &amp;quot;x&amp;quot;,&lt;br /&gt;
       &amp;quot;y&amp;quot;,&lt;br /&gt;
       &amp;quot;z&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    gamma: {&lt;br /&gt;
       &amp;quot;a&amp;quot;: 3.2,&lt;br /&gt;
       &amp;quot;b&amp;quot;: true&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/javascript&amp;gt;&lt;br /&gt;
the contents of the string returned would be:&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;alpha&amp;quot; ] )        ⇒    1&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;beta&amp;quot; ] )         ⇒    [ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ]&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;beta&amp;quot;, 2 ] )      ⇒    z&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;gamma&amp;quot;, &amp;quot;a&amp;quot; ] )   ⇒    3.2&lt;br /&gt;
&amp;lt;/lsl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
llJsonSetValue(string json, list specifiers, string value_to_set) will force the resulting JSON to conform with the specifiers supplied, as long as the specified path is traversable.&lt;br /&gt;
&lt;br /&gt;
==Json Interrogation and Validation==&lt;br /&gt;
&lt;br /&gt;
To determine the type of a json value:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;lsl&amp;gt;string type = llJsonValueType( string json, list specifiers );&amp;lt;/lsl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:returns one of several following special constants (see table below). Each constant has a name, JSON_XXXX, which unlike most LSL constants is not an integer—instead, it&#039;s a single-character string. The single character is not printable but has a specific escape value (if run through llEscapeURL) in the range of  %EF%B7%90–97. The below table shows each constant&#039;s invocation and escape code:&lt;br /&gt;
&lt;br /&gt;
{{LSL Constants/JSON}}&lt;br /&gt;
&lt;br /&gt;
==Json to LSL Conversion==&lt;br /&gt;
&lt;br /&gt;
To directly extract a Json value to an LSL string:&lt;br /&gt;
&lt;br /&gt;
 string value = llJsonGetValue( string json, list specifiers );&lt;br /&gt;
* &#039;&#039;json&#039;&#039; is a string containing a valid json array or object value&lt;br /&gt;
* &#039;&#039;specifiers&#039;&#039; is a list of specifiers (see Specifying Json Elements)&lt;br /&gt;
* returns a json string&lt;br /&gt;
* if the specifiers do not indicate a value that exists in the input, [[JSON_INVALID]] is returned&lt;br /&gt;
&lt;br /&gt;
To convert a json compound value (either an array or an object) to an LSL List:&lt;br /&gt;
&lt;br /&gt;
 list values = llJson2List( string json );&lt;br /&gt;
* &#039;&#039;json&#039;&#039; is a string containing a valid json array or object value&lt;br /&gt;
* If the string in json is not a valid json object or array a list with a single item matching the conversion above is returned.&lt;br /&gt;
&lt;br /&gt;
==Recursive Parsing==&lt;br /&gt;
&lt;br /&gt;
Since any value in a Json array or object may be any arbitrary type, including an array or object, the parsing methods must handle nested values.  Nested arrays or objects are not converted, but remain LSL String values.  If an LSL script needs to use the components in such a nested value, it must explicitly pass that string to the appropriate method.  For example, the following json value is passed to llJson2List:&lt;br /&gt;
&amp;lt;javascript&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    alpha: 1,&lt;br /&gt;
    beta: [&lt;br /&gt;
       &amp;quot;x&amp;quot;,&lt;br /&gt;
       &amp;quot;y&amp;quot;,&lt;br /&gt;
       &amp;quot;z&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    gamma: {&lt;br /&gt;
       a: 3.2,&lt;br /&gt;
       b: true&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/javascript&amp;gt;&lt;br /&gt;
The result would be an LSL list with a stride of 2: the first elements of the 3 strides would be &amp;quot;alpha&amp;quot;, &amp;quot;beta&amp;quot;, and &amp;quot;gamma&amp;quot;.  The second element of the first stride would be the integer 1, but the second elements of the other two strides would be LSL strings containing the json representation of the array &#039;[ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ]&#039; and object &#039;{ a: 3.2, b: true }&#039; respectively.&lt;br /&gt;
&lt;br /&gt;
==LSL to Json==&lt;br /&gt;
&lt;br /&gt;
To convert a list to json:&lt;br /&gt;
 string json = llList2Json( string type, list values );&lt;br /&gt;
* &#039;&#039;type&#039;&#039; must be either [[JSON_ARRAY]] or [[JSON_OBJECT]]&lt;br /&gt;
* &#039;&#039;values&#039;&#039; is the list to be converted to json.&lt;br /&gt;
&lt;br /&gt;
:Produces an LSL String containing a Json compound value, either an array or an object depending on type, containing the values in the input list.  &lt;br /&gt;
&lt;br /&gt;
:If type is [[JSON_ARRAY]], the list may contain values of any LSL type; they are converted as described in Type Conversions above.  &lt;br /&gt;
&lt;br /&gt;
:If type is [[JSON_OBJECT]], the list must have a stride of 2.  The first value of each stride must be a string.  The second value of each stride may be any LSL type, and are converted as described in Type Conversions above. [[JSON_INVALID]] is returned if the stride is not 2.&lt;br /&gt;
&lt;br /&gt;
:[[JSON_INVALID]] is returned if any other string or json type is specified as the type.&lt;br /&gt;
&lt;br /&gt;
To directly set a Json value within a string:&lt;br /&gt;
&lt;br /&gt;
 string jsonresult = llJsonSetValue( string json, list specifiers, string value );&lt;br /&gt;
* &#039;&#039;json&#039;&#039; is a string containing a valid json array or object value&lt;br /&gt;
* &#039;&#039;specifiers&#039;&#039; is a list of specifiers (see [[#Specifying Json Elements]])&lt;br /&gt;
* &#039;&#039;value&#039;&#039; the value to be inserted into the specified place in json&lt;br /&gt;
* Returns the newly modified json string&lt;br /&gt;
&lt;br /&gt;
:The only failure mode for llJsonSetValue is if an array index is specified in specifiers that is negative (but not [[JSON_APPEND]]) or more greater than the list size. In all other cases the json is modified so that the set can succeed. For example if an integer is specified for a level that is an object, the object will be removed completely and replaced with an array. If the object key does not exist it will be added, and JSON_APPEND or an index one larger than the last item in an array can be used to append to an array. These features are to allow building a Json string with llJsonSetValue.&lt;br /&gt;
&lt;br /&gt;
==Recursive Construction of Compound Json Values==&lt;br /&gt;
&lt;br /&gt;
Since LSL does not support nested lists, the construction method may only be used to convert a single level; to create a Json array or object whose values are nested arrays or objects, the LSL script must first construct the nested values and then pass those values as strings to another construction method call.  For example, to construct the Json value:&lt;br /&gt;
&amp;lt;javascript&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    alpha: 1,&lt;br /&gt;
    beta: [&lt;br /&gt;
       &amp;quot;x&amp;quot;,&lt;br /&gt;
       &amp;quot;y&amp;quot;,&lt;br /&gt;
       &amp;quot;z&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    gamma: {&lt;br /&gt;
       a: 3.2,&lt;br /&gt;
       b: true&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/javascript&amp;gt;&lt;br /&gt;
The following sequence could be used:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
string gamma_value = llList2Json( JSON_OBJECT, [ &amp;quot;a&amp;quot;, 3.2, &amp;quot;b&amp;quot;, TRUE ] );&lt;br /&gt;
string beta_value  = llList2Json( JSON_ARRAY, [ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ] );&lt;br /&gt;
string value       = llList2Json( JSON_OBJECT,[ &amp;quot;alpha&amp;quot;, 1, &amp;quot;beta&amp;quot;, beta_value, &amp;quot;gamma&amp;quot;, gamma_value ] );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or the equivalent without the intermediate variables:&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
string value =&lt;br /&gt;
    llList2Json( JSON_OBJECT,&lt;br /&gt;
        [&amp;quot;alpha&amp;quot;, 1,&lt;br /&gt;
         &amp;quot;beta&amp;quot;, llList2Json( JSON_ARRAY, [ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ] ),&lt;br /&gt;
         &amp;quot;gamma&amp;quot;, llList2Json( JSON_OBJECT, [ &amp;quot;a&amp;quot;, 3.2, &amp;quot;b&amp;quot;, TRUE ] )]&lt;br /&gt;
    );&lt;br /&gt;
&amp;lt;/lsl&amp;gt;&lt;/div&gt;</summary>
		<author><name>Gistya Eusebio</name></author>
	</entry>
	<entry>
		<id>https://wiki.secondlife.com/w/index.php?title=Json_usage_in_LSL&amp;diff=1179334</id>
		<title>Json usage in LSL</title>
		<link rel="alternate" type="text/html" href="https://wiki.secondlife.com/w/index.php?title=Json_usage_in_LSL&amp;diff=1179334"/>
		<updated>2013-06-19T22:05:36Z</updated>

		<summary type="html">&lt;p&gt;Gistya Eusebio: spelling correction&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{LSL Header|lm=*}}{{LSLC|}}{{LSLC|JSON|*Json usage in LSL}}&lt;br /&gt;
==Type Conversions==&lt;br /&gt;
&lt;br /&gt;
Json has native representation for:&lt;br /&gt;
* numbers - directly mappable to LSL Integer and Float (json numbers without a decimal point are assumed to be Integers, those with a decimal point are Floats)&lt;br /&gt;
* strings - identical to LSL [[String]]&lt;br /&gt;
* arrays - a list of values of any type: directly analogous to an LSL [[List]]&lt;br /&gt;
* objects - represented in LSL as a strided list of name/value pairs (see below re: values)&lt;br /&gt;
* the constants &#039;true&#039; and &#039;false&#039; - directly mapped to and from the LSL constants [[JSON_TRUE]] and [[JSON_FALSE]]&lt;br /&gt;
* the constant &#039;null&#039; - directly mapped to and from the LSL constant [[JSON_NULL]]&lt;br /&gt;
* All other LSL types (Key, Rotation, and Vector) are implicitly converted to their string representation when converting to Json; when converting from Json to LSL, these values are returned as String values, so the script must explicitly convert using the existing conversion methods.&lt;br /&gt;
&lt;br /&gt;
==New LSL Methods==&lt;br /&gt;
===Specifying Json Elements===&lt;br /&gt;
&lt;br /&gt;
[[llJsonGetValue]], [[llJsonValueType]] and [[llJsonSetValue]] each take the same first two arguments:&lt;br /&gt;
  1. a JSON value in the form of a [[String|string]], and   &lt;br /&gt;
  2. a set of specifiers in the form of a [[List|list]].&lt;br /&gt;
[[llJsonSetValue]] additionally takes a third an argument: &lt;br /&gt;
  3. a JSON value in the form of a [[String|string]]. &lt;br /&gt;
&lt;br /&gt;
To understand specifiers one must generally understand that JSON data is structured in a [http://en.wikipedia.org/wiki/Nested_set_model nested set model]. LSL&#039;s built-in JSON parser uses the supplied &amp;quot;specifiers&amp;quot; list to perform [http://en.wikipedia.org/wiki/Tree_traversal tree traversal] on the nodes of the supplied JSON [http://en.wikipedia.org/wiki/Tree_(data_structure) tree data structure]. A JSON tree may be visualized as a set of hierarchical levels of parents and children. Each level is contained within &#039;&#039;&#039;curly braces {for objects, which are lists of members, that are defined as key-value pairs}&#039;&#039;&#039; or &#039;&#039;&#039;square braces [for arrays of elements, that are defined as single values]&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
When JSON is presented in human-readable form, it is traditionally formatted such that the first parent level of organization is indented farthest to the left, and each more deeply-nested child level of organization is indented farther and farther to the right. The left-most level of nodes have no parents, only children. They begin with the very first member that appears after the initial &amp;quot;{&amp;quot; character of the JSON string (if it starts as an object), or the first element that appears after the initial &amp;quot;[&amp;quot; character (if it starts as an array). A node is considered as being a parent only if it has a non-null JSON object or array as its value.&lt;br /&gt;
&lt;br /&gt;
With that parent-child tree data structure in mind, the specifiers list that you supply in the above functions tell LSL&#039;s JSON parser how to [http://en.wikipedia.org/wiki/Tree_(data_structure)#Traversal_methods walk the tree] of the JSON data that you have supplied with the first argument of the function. The first specifier in the list tells the LSL JSON parser which node to walk to first. The next specifier tells it which of that node&#039;s children to walk to. Once the LSL parser has &amp;quot;walked&amp;quot; to the last destination node specified by your list of specifiers, it will then perform the function on the JSON value that it finds there. &lt;br /&gt;
&lt;br /&gt;
If, anywhere along the line, any of the specified nodes do not exist, [[llJsonGetValue]] and [[llJsonValueType]] will almost always return [[JSON_INVALID]]. However there is a rare exception: if any specifier in the list leads to a node that has no characters in its JSON string value, JSON_NULL will be returned instead of JSON_INVALID—no matter what might come after it in the specifiers list. For example in:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
string parent = &amp;quot;{\&amp;quot;parent\&amp;quot;:,}&amp;quot;; &lt;br /&gt;
string test1 = llJsonGetValue(example,[parent]);&lt;br /&gt;
string test2 = llJsonGetValue(example,[&amp;quot;parent&amp;quot;,&amp;quot;child that doesn&#039;t exist&amp;quot;,&amp;quot;etc.&amp;quot;]);&lt;br /&gt;
&amp;lt;/lsl&amp;gt; &lt;br /&gt;
test1 and test2 will both be JSON_NULL. &lt;br /&gt;
&lt;br /&gt;
The same is true for arrays: a specifier pointing to any element of a valid array will return JSON_NULL anywhere there is no JSON value specified at given position in the array:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
string &amp;quot;{\&amp;quot;parent\&amp;quot;:[ , ,  , , ]}&amp;quot;;&lt;br /&gt;
string test1 = llJsonGetValue(example,[&amp;quot;parent&amp;quot;,2]);&lt;br /&gt;
string test2 = llJsonGetValue(example,[&amp;quot;parent&amp;quot;,1,&amp;quot;child that does not exist&amp;quot;,&amp;quot;etc.&amp;quot;]);&lt;br /&gt;
&amp;lt;/lsl&amp;gt;&lt;br /&gt;
test1 and test2 will also both be JSON_NULL. &lt;br /&gt;
&lt;br /&gt;
These types of scenarios may be useful in determining valid JSON paths for the setter: in all the scenarios where JSON_NULL is returned, the same set of specifiers is able to be successfully used for [[llJsonSetValue]]. However if [[JSON_INVALID]] is returned, there is no guarantee the setter won&#039;t return an error.&lt;br /&gt;
&lt;br /&gt;
For [[llJsonGetValue]], if a JSON value is present, it will be returned by the function. The value may an object that contains no valid JSON data, so be careful. Such an object will be deemed a [[JSON_OBJECT]] by [[llJsonValueType]], even if its contents are not valid JSON. Therefore it&#039;s always best to check the [[llJsonGetType]] of any specified value to make sure it&#039;s valid before using the information in your script. &lt;br /&gt;
&lt;br /&gt;
The specifiers list may only consist of strings/keys (for object member keys), and integers (for array element positions), which define a path to the desired value in a JSON compound object.&lt;br /&gt;
&lt;br /&gt;
* An empty list specifies the entire Json value.&lt;br /&gt;
* If the list is not empty, each element of the list is used to select the element at the same level of nesting in the JSON value:&lt;br /&gt;
** if the specifier list element is a string, then the corresponding element in the json value must be an object and the list element selects the value whose JSON name exactly matches the string.&lt;br /&gt;
** if the specifier list element is an integer, then the corresponding element in the json value must be an array and the list element is used as a zero-based index into the Json array.&lt;br /&gt;
* Additionally llJsonSetValue accepts [[JSON_APPEND]] as a specifier to indicate appending the value to the end of the array at that level. Be careful because If the value at that level is not an array, it will be overwritten and replaced with the array you&#039;re setting! &lt;br /&gt;
&lt;br /&gt;
For example, given the JSON value:&lt;br /&gt;
&amp;lt;javascript&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    alpha: 1,&lt;br /&gt;
    beta: [&lt;br /&gt;
       &amp;quot;x&amp;quot;,&lt;br /&gt;
       &amp;quot;y&amp;quot;,&lt;br /&gt;
       &amp;quot;z&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    gamma: {&lt;br /&gt;
       &amp;quot;a&amp;quot;: 3.2,&lt;br /&gt;
       &amp;quot;b&amp;quot;: true&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/javascript&amp;gt;&lt;br /&gt;
the contents of the string returned would be:&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;alpha&amp;quot; ] )        ⇒    1&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;beta&amp;quot; ] )         ⇒    [ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ]&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;beta&amp;quot;, 2 ] )      ⇒    z&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;gamma&amp;quot;, &amp;quot;a&amp;quot; ] )   ⇒    3.2&lt;br /&gt;
&amp;lt;/lsl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
llJsonSetValue(string json, list specifiers, string value_to_set) will force the resulting JSON to conform with the specifiers supplied, as long as the specified path is traversable.&lt;br /&gt;
&lt;br /&gt;
==Json Interrogation and Validation==&lt;br /&gt;
&lt;br /&gt;
To determine the type of a json value:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;lsl&amp;gt;string type = llJsonValueType( string json, list specifiers );&amp;lt;/lsl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:returns one of several following special constants (see table below). Each constant has a name, JSON_XXXX, which unlike most LSL constants is not an integer—instead, it&#039;s a single-character string. The single character is not printable but has a specific escape value (if run through llEscapeURL) in the range of  %EF%B7%90–97. The below table shows each constant&#039;s invocation and escape code:&lt;br /&gt;
&lt;br /&gt;
{{LSL Constants/JSON}}&lt;br /&gt;
&lt;br /&gt;
==Json to LSL Conversion==&lt;br /&gt;
&lt;br /&gt;
To directly extract a Json value to an LSL string:&lt;br /&gt;
&lt;br /&gt;
 string value = llJsonGetValue( string json, list specifiers );&lt;br /&gt;
* &#039;&#039;json&#039;&#039; is a string containing a valid json array or object value&lt;br /&gt;
* &#039;&#039;specifiers&#039;&#039; is a list of specifiers (see Specifying Json Elements)&lt;br /&gt;
* returns a json string&lt;br /&gt;
* if the specifiers do not indicate a value that exists in the input, [[JSON_INVALID]] is returned&lt;br /&gt;
&lt;br /&gt;
To convert a json compound value (either an array or an object) to an LSL List:&lt;br /&gt;
&lt;br /&gt;
 list values = llJson2List( string json );&lt;br /&gt;
* &#039;&#039;json&#039;&#039; is a string containing a valid json array or object value&lt;br /&gt;
* If the string in json is not a valid json object or array a list with a single item matching the conversion above is returned.&lt;br /&gt;
&lt;br /&gt;
==Recursive Parsing==&lt;br /&gt;
&lt;br /&gt;
Since any value in a Json array or object may be any arbitrary type, including an array or object, the parsing methods must handle nested values.  Nested arrays or objects are not converted, but remain LSL String values.  If an LSL script needs to use the components in such a nested value, it must explicitly pass that string to the appropriate method.  For example, the following json value is passed to llJson2List:&lt;br /&gt;
&amp;lt;javascript&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    alpha: 1,&lt;br /&gt;
    beta: [&lt;br /&gt;
       &amp;quot;x&amp;quot;,&lt;br /&gt;
       &amp;quot;y&amp;quot;,&lt;br /&gt;
       &amp;quot;z&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    gamma: {&lt;br /&gt;
       a: 3.2,&lt;br /&gt;
       b: true&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/javascript&amp;gt;&lt;br /&gt;
The result would be an LSL list with a stride of 2: the first elements of the 3 strides would be &amp;quot;alpha&amp;quot;, &amp;quot;beta&amp;quot;, and &amp;quot;gamma&amp;quot;.  The second element of the first stride would be the integer 1, but the second elements of the other two strides would be LSL strings containing the json representation of the array &#039;[ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ]&#039; and object &#039;{ a: 3.2, b: true }&#039; respectively.&lt;br /&gt;
&lt;br /&gt;
==LSL to Json==&lt;br /&gt;
&lt;br /&gt;
To convert a list to json:&lt;br /&gt;
 string json = llList2Json( string type, list values );&lt;br /&gt;
* &#039;&#039;type&#039;&#039; must be either [[JSON_ARRAY]] or [[JSON_OBJECT]]&lt;br /&gt;
* &#039;&#039;values&#039;&#039; is the list to be converted to json.&lt;br /&gt;
&lt;br /&gt;
:Produces an LSL String containing a Json compound value, either an array or an object depending on type, containing the values in the input list.  &lt;br /&gt;
&lt;br /&gt;
:If type is [[JSON_ARRAY]], the list may contain values of any LSL type; they are converted as described in Type Conversions above.  &lt;br /&gt;
&lt;br /&gt;
:If type is [[JSON_OBJECT]], the list must have a stride of 2.  The first value of each stride must be a string.  The second value of each stride may be any LSL type, and are converted as described in Type Conversions above. [[JSON_INVALID]] is returned if the stride is not 2.&lt;br /&gt;
&lt;br /&gt;
:[[JSON_INVALID]] is returned if any other string or json type is specified as the type.&lt;br /&gt;
&lt;br /&gt;
To directly set a Json value within a string:&lt;br /&gt;
&lt;br /&gt;
 string jsonresult = llJsonSetValue( string json, list specifiers, string value );&lt;br /&gt;
* &#039;&#039;json&#039;&#039; is a string containing a valid json array or object value&lt;br /&gt;
* &#039;&#039;specifiers&#039;&#039; is a list of specifiers (see [[#Specifying Json Elements]])&lt;br /&gt;
* &#039;&#039;value&#039;&#039; the value to be inserted into the specified place in json&lt;br /&gt;
* Returns the newly modified json string&lt;br /&gt;
&lt;br /&gt;
:The only failure mode for llJsonSetValue is if an array index is specified in specifiers that is negative (but not [[JSON_APPEND]]) or more greater than the list size. In all other cases the json is modified so that the set can succeed. For example if an integer is specified for a level that is an object, the object will be removed completely and replaced with an array. If the object key does not exist it will be added, and JSON_APPEND or an index one larger than the last item in an array can be used to append to an array. These features are to allow building a Json string with llJsonSetValue.&lt;br /&gt;
&lt;br /&gt;
==Recursive Construction of Compound Json Values==&lt;br /&gt;
&lt;br /&gt;
Since LSL does not support nested lists, the construction method may only be used to convert a single level; to create a Json array or object whose values are nested arrays or objects, the LSL script must first construct the nested values and then pass those values as strings to another construction method call.  For example, to construct the Json value:&lt;br /&gt;
&amp;lt;javascript&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    alpha: 1,&lt;br /&gt;
    beta: [&lt;br /&gt;
       &amp;quot;x&amp;quot;,&lt;br /&gt;
       &amp;quot;y&amp;quot;,&lt;br /&gt;
       &amp;quot;z&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    gamma: {&lt;br /&gt;
       a: 3.2,&lt;br /&gt;
       b: true&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/javascript&amp;gt;&lt;br /&gt;
The following sequence could be used:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
string gamma_value = llList2Json( JSON_OBJECT, [ &amp;quot;a&amp;quot;, 3.2, &amp;quot;b&amp;quot;, TRUE ] );&lt;br /&gt;
string beta_value  = llList2Json( JSON_ARRAY, [ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ] );&lt;br /&gt;
string value       = llList2Json( JSON_OBJECT,[ &amp;quot;alpha&amp;quot;, 1, &amp;quot;beta&amp;quot;, beta_value, &amp;quot;gamma&amp;quot;, gamma_value ] );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or the equivalent without the intermediate variables:&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
string value =&lt;br /&gt;
    llList2Json( JSON_OBJECT,&lt;br /&gt;
        [&amp;quot;alpha&amp;quot;, 1,&lt;br /&gt;
         &amp;quot;beta&amp;quot;, llList2Json( JSON_ARRAY, [ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ] ),&lt;br /&gt;
         &amp;quot;gamma&amp;quot;, llList2Json( JSON_OBJECT, [ &amp;quot;a&amp;quot;, 3.2, &amp;quot;b&amp;quot;, TRUE ] )]&lt;br /&gt;
    );&lt;br /&gt;
&amp;lt;/lsl&amp;gt;&lt;/div&gt;</summary>
		<author><name>Gistya Eusebio</name></author>
	</entry>
	<entry>
		<id>https://wiki.secondlife.com/w/index.php?title=Json_usage_in_LSL&amp;diff=1179330</id>
		<title>Json usage in LSL</title>
		<link rel="alternate" type="text/html" href="https://wiki.secondlife.com/w/index.php?title=Json_usage_in_LSL&amp;diff=1179330"/>
		<updated>2013-06-19T17:26:16Z</updated>

		<summary type="html">&lt;p&gt;Gistya Eusebio: further formatting and corrections on my change&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{LSL Header|lm=*}}{{LSLC|}}{{LSLC|JSON|*Json usage in LSL}}&lt;br /&gt;
==Type Conversions==&lt;br /&gt;
&lt;br /&gt;
Json has native representation for:&lt;br /&gt;
* numbers - directly mappable to LSL Integer and Float (json numbers without a decimal point are assumed to be Integers, those with a decimal point are Floats)&lt;br /&gt;
* strings - identical to LSL [[String]]&lt;br /&gt;
* arrays - a list of values of any type: directly analogous to an LSL [[List]]&lt;br /&gt;
* objects - represented in LSL as a strided list of name/value pairs (see below re: values)&lt;br /&gt;
* the constants &#039;true&#039; and &#039;false&#039; - directly mapped to and from the LSL constants [[JSON_TRUE]] and [[JSON_FALSE]]&lt;br /&gt;
* the constant &#039;null&#039; - directly mapped to and from the LSL constant [[JSON_NULL]]&lt;br /&gt;
* All other LSL types (Key, Rotation, and Vector) are implicitly converted to their string representation when converting to Json; when converting from Json to LSL, these values are returned as String values, so the script must explicitly convert using the existing conversion methods.&lt;br /&gt;
&lt;br /&gt;
==New LSL Methods==&lt;br /&gt;
===Specifying Json Elements===&lt;br /&gt;
&lt;br /&gt;
[[llJsonGetValue]], [[llJsonValueType]] and [[llJsonSetValue]] each take the same first two arguments:&lt;br /&gt;
  1. a JSON value in the form of a [[String|string]], and   &lt;br /&gt;
  2. a set of specifiers in the form of a [[List|list]].&lt;br /&gt;
[[llJsonSetValue]] additionally takes a third an argument: &lt;br /&gt;
  3. a JSON value in the form of a [[String|string]]. &lt;br /&gt;
&lt;br /&gt;
To understand specifiers one must generally understand that JSON data is structured in a [http://en.wikipedia.org/wiki/Nested_set_model nested set model]. LSL&#039;s built-in JSON parser uses the supplied &amp;quot;specifiers&amp;quot; list to perform [http://en.wikipedia.org/wiki/Tree_traversal tree traversal] on the nodes of the supplied JSON [http://en.wikipedia.org/wiki/Tree_(data_structure) tree data structure]. A JSON tree may be visualized as a set of hierarchical levels of parents and children. Each level is contained within &#039;&#039;&#039;curly braces {for objects, which are lists of members, that are defined as key-value pairs}&#039;&#039;&#039; or &#039;&#039;&#039;square braces [for arrays of elements, that are defined as single values]&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
When JSON is presented in human-readable form, it is traditionally formatted such that the first parent level of organization is indented farthest to the left, and each more deeply-nested child level of organization is indented farther and farther to the right. The left-most level of nodes have no parents, only children. They begin with the very first member that appears after the initial &amp;quot;{&amp;quot; character of the JSON string (if it starts as an object), or the first element that appears after the initial &amp;quot;[&amp;quot; character (if it starts as an array). A node is considered as being a parent only if it has a non-null JSON object or array as its value.&lt;br /&gt;
&lt;br /&gt;
With that parent-child tree data structure in mind, the specifiers list that you supply in the above functions tell LSL&#039;s JSON parser how to [http://en.wikipedia.org/wiki/Tree_(data_structure)#Traversal_methods walk the tree] of the JSON data that you have supplied with the first argument of the function. The first specifier in the list tells the LSL JSON parser which node to walk to first. The next specifier tells it which of that node&#039;s children to walk to. Once the LSL parser has &amp;quot;walked&amp;quot; to the last destination node specified by your list of specifiers, it will then perform the function on the JSON value that it finds there. &lt;br /&gt;
&lt;br /&gt;
If, anywhere along the line, any of the specified nodes do not exist, [[llJsonGetValue]] and [[llJsonValueType]] will almost always return [[JSON_INVALID]]. However there is a rare exception: if any specifier in the list leads to a node that has no characters in its JSON string value, JSON_NULL will be returned instead of JSON_INVALID—no matter what might come after it in the specifiers list. For example in:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
string parent = &amp;quot;{\&amp;quot;parent\&amp;quot;:,}&amp;quot;; &lt;br /&gt;
string test1 = llJsonGetValue(example,[parent]);&lt;br /&gt;
string test2 = llJsonGetValue(example,[&amp;quot;parent&amp;quot;,&amp;quot;child that doesn&#039;t exist&amp;quot;,&amp;quot;etc.&amp;quot;]);&lt;br /&gt;
&amp;lt;/lsl&amp;gt; &lt;br /&gt;
test1 and test2 will both be JSON_NULL. &lt;br /&gt;
&lt;br /&gt;
The same is true for arrays: a specifier pointing to any element of a valid array will return JSON_NULL anywhere there is no JSON value specified at given position in the array:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
string &amp;quot;{\&amp;quot;parent\&amp;quot;:[ , ,  , , ]}&amp;quot;;&lt;br /&gt;
string test1 = llJsonGetValue(example,[&amp;quot;parent&amp;quot;,2]);&lt;br /&gt;
string test2 = llJsonGetValue(example,[&amp;quot;parent&amp;quot;,1,&amp;quot;child that does not exist&amp;quot;,&amp;quot;etc.&amp;quot;]);&lt;br /&gt;
&amp;lt;/lsl&amp;gt;&lt;br /&gt;
test1 and test2 will also both be JSON_NULL. &lt;br /&gt;
&lt;br /&gt;
These types of scenarios may be useful in determining valid JSON paths for the setter: in all the scenarios where JSON_NULL is returned, the same set of specifiers is able to be successfully used for [[llJsonSetValue]]. However if [[JSON_INVALID]] is returned, there is no guarantee the setter won&#039;t return an error.&lt;br /&gt;
&lt;br /&gt;
For [[llJsonGetValue]], if a JSON value is present, it will be returned by the function. The value may an object that contains no valid JSON data, so be careful. Such an object will be deemed a [[JSON_OBJECT]] by [[llGetJsonType]], even if its contents are not valid JSON. Therefore it&#039;s always best to check the [[llJsonGetType]] of any specified value to make sure it&#039;s valid before using the information in your script. &lt;br /&gt;
&lt;br /&gt;
The specifiers list may only consist of strings/keys (for object member keys), and integers (for array element positions), which define a path to the desired value in a JSON compound object.&lt;br /&gt;
&lt;br /&gt;
* An empty list specifies the entire Json value.&lt;br /&gt;
* If the list is not empty, each element of the list is used to select the element at the same level of nesting in the JSON value:&lt;br /&gt;
** if the specifier list element is a string, then the corresponding element in the json value must be an object and the list element selects the value whose JSON name exactly matches the string.&lt;br /&gt;
** if the specifier list element is an integer, then the corresponding element in the json value must be an array and the list element is used as a zero-based index into the Json array.&lt;br /&gt;
* Additionally llJsonSetValue accepts [[JSON_APPEND]] as a specifier to indicate appending the value to the end of the array at that level. Be careful because If the value at that level is not an array, it will be overwritten and replaced with the array you&#039;re setting! &lt;br /&gt;
&lt;br /&gt;
For example, given the JSON value:&lt;br /&gt;
&amp;lt;javascript&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    alpha: 1,&lt;br /&gt;
    beta: [&lt;br /&gt;
       &amp;quot;x&amp;quot;,&lt;br /&gt;
       &amp;quot;y&amp;quot;,&lt;br /&gt;
       &amp;quot;z&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    gamma: {&lt;br /&gt;
       &amp;quot;a&amp;quot;: 3.2,&lt;br /&gt;
       &amp;quot;b&amp;quot;: true&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/javascript&amp;gt;&lt;br /&gt;
the contents of the string returned would be:&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;alpha&amp;quot; ] )        ⇒    1&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;beta&amp;quot; ] )         ⇒    [ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ]&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;beta&amp;quot;, 2 ] )      ⇒    z&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;gamma&amp;quot;, &amp;quot;a&amp;quot; ] )   ⇒    3.2&lt;br /&gt;
&amp;lt;/lsl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
llJsonSetValue(string json, list specifiers, string value_to_set) will force the resulting JSON to conform with the specifiers supplied, as long as the specified path is traversable.&lt;br /&gt;
&lt;br /&gt;
==Json Interrogation and Validation==&lt;br /&gt;
&lt;br /&gt;
To determine the type of a json value:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;lsl&amp;gt;string type = llJsonValueType( string json, list specifiers );&amp;lt;/lsl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:returns one of several following special constants (see table below). Each constant has a name, JSON_XXXX, which unlike most LSL constants is not an integer—instead, it&#039;s a single-character string. The single character is not printable but has a specific escape value (if run through llEscapeURL) in the range of  %EF%B7%90–97. The below table shows each constant&#039;s invocation and escape code:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Contant !! Escape value&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_INVALID]] || %EF%B7%90&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_OBJECT]] || %EF%B7%91&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_ARRAY]] || %EF%B7%92&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_NUMBER]] || %EF%B7%93&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_STRING]] || %EF%B7%94&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_NULL]] || %EF%B7%95&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_TRUE]] || %EF%B7%96&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_FALSE]] || %EF%B7%97&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Json to LSL Conversion==&lt;br /&gt;
&lt;br /&gt;
To directly extract a Json value to an LSL string:&lt;br /&gt;
&lt;br /&gt;
 string value = llJsonGetValue( string json, list specifiers );&lt;br /&gt;
* &#039;&#039;json&#039;&#039; is a string containing a valid json array or object value&lt;br /&gt;
* &#039;&#039;specifiers&#039;&#039; is a list of specifiers (see Specifying Json Elements)&lt;br /&gt;
* returns a json string&lt;br /&gt;
* if the specifiers do not indicate a value that exists in the input, [[JSON_INVALID]] is returned&lt;br /&gt;
&lt;br /&gt;
To convert a json compound value (either an array or an object) to an LSL List:&lt;br /&gt;
&lt;br /&gt;
 list values = llJson2List( string json );&lt;br /&gt;
* &#039;&#039;json&#039;&#039; is a string containing a valid json array or object value&lt;br /&gt;
* If the string in json is not a valid json object or array a list with a single item matching the conversion above is returned.&lt;br /&gt;
&lt;br /&gt;
==Recursive Parsing==&lt;br /&gt;
&lt;br /&gt;
Since any value in a Json array or object may be any arbitrary type, including an array or object, the parsing methods must handle nested values.  Nested arrays or objects are not converted, but remain LSL String values.  If an LSL script needs to use the components in such a nested value, it must explicitly pass that string to the appropriate method.  For example, the following json value is passed to llJson2List:&lt;br /&gt;
&amp;lt;javascript&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    alpha: 1,&lt;br /&gt;
    beta: [&lt;br /&gt;
       &amp;quot;x&amp;quot;,&lt;br /&gt;
       &amp;quot;y&amp;quot;,&lt;br /&gt;
       &amp;quot;z&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    gamma: {&lt;br /&gt;
       a: 3.2,&lt;br /&gt;
       b: true&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/javascript&amp;gt;&lt;br /&gt;
The result would be an LSL list with a stride of 2: the first elements of the 3 strides would be &amp;quot;alpha&amp;quot;, &amp;quot;beta&amp;quot;, and &amp;quot;gamma&amp;quot;.  The second element of the first stride would be the integer 1, but the second elements of the other two strides would be LSL strings containing the json representation of the array &#039;[ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ]&#039; and object &#039;{ a: 3.2, b: true }&#039; respectively.&lt;br /&gt;
&lt;br /&gt;
==LSL to Json==&lt;br /&gt;
&lt;br /&gt;
To convert a list to json:&lt;br /&gt;
 string json = llList2Json( string type, list values );&lt;br /&gt;
* &#039;&#039;type&#039;&#039; must be either [[JSON_ARRAY]] or [[JSON_OBJECT]]&lt;br /&gt;
* &#039;&#039;values&#039;&#039; is the list to be converted to json.&lt;br /&gt;
&lt;br /&gt;
:Produces an LSL String containing a Json compound value, either an array or an object depending on type, containing the values in the input list.  &lt;br /&gt;
&lt;br /&gt;
:If type is [[JSON_ARRAY]], the list may contain values of any LSL type; they are converted as described in Type Conversions above.  &lt;br /&gt;
&lt;br /&gt;
:If type is [[JSON_OBJECT]], the list must have a stride of 2.  The first value of each stride must be a string.  The second value of each stride may be any LSL type, and are converted as described in Type Conversions above. [[JSON_INVALID] is returned if the stride is not 2.&lt;br /&gt;
&lt;br /&gt;
:[[JSON_INVALID]] is returned if any other string or json type is specified as the type.&lt;br /&gt;
&lt;br /&gt;
To directly set a Json value within a string:&lt;br /&gt;
&lt;br /&gt;
 string jsonresult = llJsonSetValue( string json, list specifiers, string value );&lt;br /&gt;
* &#039;&#039;json&#039;&#039; is a string containing a valid json array or object value&lt;br /&gt;
* &#039;&#039;specifiers&#039;&#039; is a list of specifiers (see [[#Specifying Json Elements]])&lt;br /&gt;
* &#039;&#039;value&#039;&#039; the value to be inserted into the specified place in json&lt;br /&gt;
* Returns the newly modified json string&lt;br /&gt;
&lt;br /&gt;
:The only failure mode for llJsonSetValue is if an array index is specified in specifiers that is negative (but not [[JSON_APPEND]]) or more greater than the list size. In all other cases the json is modified so that the set can succeed. For example if an integer is specified for a level that is an object, the object will be removed completely and replaced with an array. If the object key does not exist it will be added, and JSON_APPEND or an index one larger than the last item in an array can be used to append to an array. These features are to allow building a Json string with llJsonSetValue.&lt;br /&gt;
&lt;br /&gt;
==Recursive Construction of Compound Json Values==&lt;br /&gt;
&lt;br /&gt;
Since LSL does not support nested lists, the construction method may only be used to convert a single level; to create a Json array or object whose values are nested arrays or objects, the LSL script must first construct the nested values and then pass those values as strings to another construction method call.  For example, to construct the Json value:&lt;br /&gt;
&amp;lt;javascript&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    alpha: 1,&lt;br /&gt;
    beta: [&lt;br /&gt;
       &amp;quot;x&amp;quot;,&lt;br /&gt;
       &amp;quot;y&amp;quot;,&lt;br /&gt;
       &amp;quot;z&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    gamma: {&lt;br /&gt;
       a: 3.2,&lt;br /&gt;
       b: true&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/javascript&amp;gt;&lt;br /&gt;
The following sequence could be used:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
string gamma_value = llList2Json( JSON_OBJECT, [ &amp;quot;a&amp;quot;, 3.2, &amp;quot;b&amp;quot;, TRUE ] );&lt;br /&gt;
string beta_value  = llList2Json( JSON_ARRAY, [ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ] );&lt;br /&gt;
string value       = llList2Json( JSON_OBJECT,[ &amp;quot;alpha&amp;quot;, 1, &amp;quot;beta&amp;quot;, beta_value, &amp;quot;gamma&amp;quot;, gamma_value ] );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or the equivalent without the intermediate variables:&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
string value =&lt;br /&gt;
    llList2Json( JSON_OBJECT,&lt;br /&gt;
        [&amp;quot;alpha&amp;quot;, 1,&lt;br /&gt;
         &amp;quot;beta&amp;quot;, llList2Json( JSON_ARRAY, [ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ] ),&lt;br /&gt;
         &amp;quot;gamma&amp;quot;, llList2Json( JSON_OBJECT, [ &amp;quot;a&amp;quot;, 3.2, &amp;quot;b&amp;quot;, TRUE ] )]&lt;br /&gt;
    );&lt;br /&gt;
&amp;lt;/lsl&amp;gt;&lt;/div&gt;</summary>
		<author><name>Gistya Eusebio</name></author>
	</entry>
	<entry>
		<id>https://wiki.secondlife.com/w/index.php?title=Json_usage_in_LSL&amp;diff=1179328</id>
		<title>Json usage in LSL</title>
		<link rel="alternate" type="text/html" href="https://wiki.secondlife.com/w/index.php?title=Json_usage_in_LSL&amp;diff=1179328"/>
		<updated>2013-06-19T17:05:00Z</updated>

		<summary type="html">&lt;p&gt;Gistya Eusebio: /* Specifying Json Elements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{LSL Header|lm=*}}{{LSLC|}}{{LSLC|JSON|*Json usage in LSL}}&lt;br /&gt;
==Type Conversions==&lt;br /&gt;
&lt;br /&gt;
Json has native representation for:&lt;br /&gt;
* numbers - directly mappable to LSL Integer and Float (json numbers without a decimal point are assumed to be Integers, those with a decimal point are Floats)&lt;br /&gt;
* strings - identical to LSL [[String]]&lt;br /&gt;
* arrays - a list of values of any type: directly analogous to an LSL [[List]]&lt;br /&gt;
* objects - represented in LSL as a strided list of name/value pairs (see below re: values)&lt;br /&gt;
* the constants &#039;true&#039; and &#039;false&#039; - directly mapped to and from the LSL constants [[JSON_TRUE]] and [[JSON_FALSE]]&lt;br /&gt;
* the constant &#039;null&#039; - directly mapped to and from the LSL constant [[JSON_NULL]]&lt;br /&gt;
* All other LSL types (Key, Rotation, and Vector) are implicitly converted to their string representation when converting to Json; when converting from Json to LSL, these values are returned as String values, so the script must explicitly convert using the existing conversion methods.&lt;br /&gt;
&lt;br /&gt;
==New LSL Methods==&lt;br /&gt;
===Specifying Json Elements===&lt;br /&gt;
&lt;br /&gt;
[[llJsonGetValue]], [[llJsonValueType]] and [[llJsonSetValue]] each take the same first two arguments:&lt;br /&gt;
  1. a JSON value in the form of a [[String|string]], and   &lt;br /&gt;
  2. a set of specifiers in the form of a [[List|list]].&lt;br /&gt;
[[llJsonSetValue]] additionally takes a third an argument: &lt;br /&gt;
  3. a JSON value in the form of a [[String|string]]. &lt;br /&gt;
&lt;br /&gt;
To understand specifiers one must generally understand that JSON data is structured in a [http://en.wikipedia.org/wiki/Nested_set_model nested set model]. LSL&#039;s built-in JSON parser uses the supplied &amp;quot;specifiers&amp;quot; list to perform [http://en.wikipedia.org/wiki/Tree_traversal tree traversal] on the nodes of the supplied JSON [http://en.wikipedia.org/wiki/Tree_(data_structure) tree data structure]. A JSON tree may be visualized as a set of hierarchical levels of parents and children. Each level is contained within &#039;&#039;&#039;curly braces {for objects, which are lists of members, that are defined as key-value pairs}&#039;&#039;&#039; or &#039;&#039;&#039;square braces [for arrays of elements, that are defined as single values]&#039;&#039;&#039;. When JSON is presented in human-readable form, it is traditionally formatted such that the first parent level of organization is indented farthest to the left, and each more deeply-nested child level of organization is indented farther and farther to the right. The left-most level of nodes have no parents, only children. They begin with the very first member that appears after the initial &amp;quot;{&amp;quot; character of the JSON string (if it starts as an object), or the first element that appears after the initial &amp;quot;[&amp;quot; character (if it starts as an array). A node is considered as being a parent only if it has a non-null JSON object or array as its value -- and if a node has no value, then its value is considered to be &amp;quot;null&amp;quot; (strings &amp;quot;{}&amp;quot; or &amp;quot;[]&amp;quot; or &amp;quot;&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
With that parent-child tree data structure in mind, the specifiers list that you supply in the above function tells tells LSL&#039;s JSON parser how to [http://en.wikipedia.org/wiki/Tree_(data_structure)#Traversal_methods walk the tree] of the JSON data that you have supplied with the first argument of the function. The first specifier in the list tells the LSL JSON parser which node to walk to first. The next specifier tells it which of that node&#039;s children to walk to. Once the LSL parser has &amp;quot;walked&amp;quot; to the last destination node specified by your list of specifiers, it will then perform the function on the JSON value that it finds there. &lt;br /&gt;
&lt;br /&gt;
If, anywhere along the line, any of the specified nodes do not exist, [[llJsonGetValue]] and [[llJsonValueType]] will almost always return [[JSON_INVALID]]. However there is a rare exception: if the specifiers list leads to a node that has no characters in its JSON string value, no matter what follows that &amp;quot;null-value node&amp;quot; in the specifiers list, JSON_NULL will be returned instead of JSON_INVALID -- even though, obviously, none of the following specifiers exist. For example, for the example object {&amp;quot;parent&amp;quot;:,} llJsonGetValue(example,[&amp;quot;parent&amp;quot;]) will return JSON_NULL, as will llJsonGetValue(example,[&amp;quot;parent&amp;quot;,&amp;quot;child that doesn&#039;t exist&amp;quot;,&amp;quot;etc.&amp;quot;]). Another example: a specifier pointing to any element of a valid array such as {&amp;quot;parent&amp;quot;:[ , ,  , , ]} will return JSON_NULL anywhere there is no JSON value specified at given position in the array; in this case llJsonGetValue(example,[&amp;quot;parent&amp;quot;,2]) returns JSON_NULL, as does llJsonGetValue(example,[&amp;quot;parent&amp;quot;,1,&amp;quot;child that does not exist&amp;quot;,&amp;quot;etc.&amp;quot;]). These rare scenarios may be useful in determining valid JSON paths for the setter: in all the scenarios where JSON_NULL is returned, the same set of specifiers is able to be used for [[llJsonSetValue]] -- whereas if JSON_INVALID is returned, there is no guarantee the setter won&#039;t return an error.&lt;br /&gt;
&lt;br /&gt;
For llJsonGetValue(), if a JSON value is present, it will be returned by the function. The value may an object that contains no valid JSON data, so be careful. Such an object will be deemed a JSON_OBJECT by llGetJsonType(), even if its contents are not valid JSON. Therefore it&#039;s always best to check the llJsonType() of any specified value to make sure it&#039;s valid before using the information in your script. &lt;br /&gt;
&lt;br /&gt;
The specifiers list may only consist of strings/keys (for object member keys), and integers (for array element positions), which define a path to the desired value in a JSON compound object.&lt;br /&gt;
&lt;br /&gt;
* An empty list specifies the entire Json value.&lt;br /&gt;
* If the list is not empty, each element of the list is used to select the element at the same level of nesting in the Json value:&lt;br /&gt;
** if the specifier list element is a string, then the corresponding element in the json value must be an object and the list element selects the value whose Json name exactly matches the string.&lt;br /&gt;
** if the specifier list element is an integer, then the corresponding element in the json value must be an array and the list element is used as a zero-based index into the Json array.&lt;br /&gt;
* Additionally llJsonSetValue accepts [[JSON_APPEND]] as a specifier to indicate appending the value to the end of the array at that level.&lt;br /&gt;
&lt;br /&gt;
For example, given the json value:&lt;br /&gt;
&amp;lt;javascript&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    alpha: 1,&lt;br /&gt;
    beta: [&lt;br /&gt;
       &amp;quot;x&amp;quot;,&lt;br /&gt;
       &amp;quot;y&amp;quot;,&lt;br /&gt;
       &amp;quot;z&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    gamma: {&lt;br /&gt;
       &amp;quot;a&amp;quot;: 3.2,&lt;br /&gt;
       &amp;quot;b&amp;quot;: true&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/javascript&amp;gt;&lt;br /&gt;
the contents of the string returned would be:&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;alpha&amp;quot; ] )        ⇒    1&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;beta&amp;quot; ] )         ⇒    [ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ]&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;beta&amp;quot;, 2 ] )      ⇒    z&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;gamma&amp;quot;, &amp;quot;a&amp;quot; ] )   ⇒    3.2&lt;br /&gt;
&amp;lt;/lsl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
llJsonSetValue(string json, list specifiers, string value_to_set) will force the resulting JSON to conform with the specifiers supplied, as long as the specified path is traversable.&lt;br /&gt;
&lt;br /&gt;
==Json Interrogation and Validation==&lt;br /&gt;
&lt;br /&gt;
To determine the type of a json value:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;lsl&amp;gt;string type = llJsonValueType( string json, list specifiers );&amp;lt;/lsl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:returns one of several following special constants (see table below). Each constant has a name, JSON_XXXX, which unlike most LSL constants is not an integer—instead, it&#039;s a single-character string. The single character is not printable but has a specific escape value (if run through llEscapeURL) in the range of  %EF%B7%90–97. The below table shows each constant&#039;s invocation and escape code:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Contant !! Escape value&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_INVALID]] || %EF%B7%90&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_OBJECT]] || %EF%B7%91&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_ARRAY]] || %EF%B7%92&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_NUMBER]] || %EF%B7%93&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_STRING]] || %EF%B7%94&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_NULL]] || %EF%B7%95&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_TRUE]] || %EF%B7%96&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_FALSE]] || %EF%B7%97&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Json to LSL Conversion==&lt;br /&gt;
&lt;br /&gt;
To directly extract a Json value to an LSL string:&lt;br /&gt;
&lt;br /&gt;
 string value = llJsonGetValue( string json, list specifiers );&lt;br /&gt;
* &#039;&#039;json&#039;&#039; is a string containing a valid json array or object value&lt;br /&gt;
* &#039;&#039;specifiers&#039;&#039; is a list of specifiers (see Specifying Json Elements)&lt;br /&gt;
* returns a json string&lt;br /&gt;
* if the specifiers do not indicate a value that exists in the input, [[JSON_INVALID]] is returned&lt;br /&gt;
&lt;br /&gt;
To convert a json compound value (either an array or an object) to an LSL List:&lt;br /&gt;
&lt;br /&gt;
 list values = llJson2List( string json );&lt;br /&gt;
* &#039;&#039;json&#039;&#039; is a string containing a valid json array or object value&lt;br /&gt;
* If the string in json is not a valid json object or array a list with a single item matching the conversion above is returned.&lt;br /&gt;
&lt;br /&gt;
==Recursive Parsing==&lt;br /&gt;
&lt;br /&gt;
Since any value in a Json array or object may be any arbitrary type, including an array or object, the parsing methods must handle nested values.  Nested arrays or objects are not converted, but remain LSL String values.  If an LSL script needs to use the components in such a nested value, it must explicitly pass that string to the appropriate method.  For example, the following json value is passed to llJson2List:&lt;br /&gt;
&amp;lt;javascript&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    alpha: 1,&lt;br /&gt;
    beta: [&lt;br /&gt;
       &amp;quot;x&amp;quot;,&lt;br /&gt;
       &amp;quot;y&amp;quot;,&lt;br /&gt;
       &amp;quot;z&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    gamma: {&lt;br /&gt;
       a: 3.2,&lt;br /&gt;
       b: true&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/javascript&amp;gt;&lt;br /&gt;
The result would be an LSL list with a stride of 2: the first elements of the 3 strides would be &amp;quot;alpha&amp;quot;, &amp;quot;beta&amp;quot;, and &amp;quot;gamma&amp;quot;.  The second element of the first stride would be the integer 1, but the second elements of the other two strides would be LSL strings containing the json representation of the array &#039;[ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ]&#039; and object &#039;{ a: 3.2, b: true }&#039; respectively.&lt;br /&gt;
&lt;br /&gt;
==LSL to Json==&lt;br /&gt;
&lt;br /&gt;
To convert a list to json:&lt;br /&gt;
 string json = llList2Json( string type, list values );&lt;br /&gt;
* &#039;&#039;type&#039;&#039; must be either [[JSON_ARRAY]] or [[JSON_OBJECT]]&lt;br /&gt;
* &#039;&#039;values&#039;&#039; is the list to be converted to json.&lt;br /&gt;
&lt;br /&gt;
:Produces an LSL String containing a Json compound value, either an array or an object depending on type, containing the values in the input list.  &lt;br /&gt;
&lt;br /&gt;
:If type is [[JSON_ARRAY]], the list may contain values of any LSL type; they are converted as described in Type Conversions above.  &lt;br /&gt;
&lt;br /&gt;
:If type is [[JSON_OBJECT]], the list must have a stride of 2.  The first value of each stride must be a string.  The second value of each stride may be any LSL type, and are converted as described in Type Conversions above. [[JSON_INVALID] is returned if the stride is not 2.&lt;br /&gt;
&lt;br /&gt;
:[[JSON_INVALID]] is returned if any other string or json type is specified as the type.&lt;br /&gt;
&lt;br /&gt;
To directly set a Json value within a string:&lt;br /&gt;
&lt;br /&gt;
 string jsonresult = llJsonSetValue( string json, list specifiers, string value );&lt;br /&gt;
* &#039;&#039;json&#039;&#039; is a string containing a valid json array or object value&lt;br /&gt;
* &#039;&#039;specifiers&#039;&#039; is a list of specifiers (see [[#Specifying Json Elements]])&lt;br /&gt;
* &#039;&#039;value&#039;&#039; the value to be inserted into the specified place in json&lt;br /&gt;
* Returns the newly modified json string&lt;br /&gt;
&lt;br /&gt;
:The only failure mode for llJsonSetValue is if an array index is specified in specifiers that is negative (but not [[JSON_APPEND]]) or more greater than the list size. In all other cases the json is modified so that the set can succeed. For example if an integer is specified for a level that is an object, the object will be removed completely and replaced with an array. If the object key does not exist it will be added, and JSON_APPEND or an index one larger than the last item in an array can be used to append to an array. These features are to allow building a Json string with llJsonSetValue.&lt;br /&gt;
&lt;br /&gt;
==Recursive Construction of Compound Json Values==&lt;br /&gt;
&lt;br /&gt;
Since LSL does not support nested lists, the construction method may only be used to convert a single level; to create a Json array or object whose values are nested arrays or objects, the LSL script must first construct the nested values and then pass those values as strings to another construction method call.  For example, to construct the Json value:&lt;br /&gt;
&amp;lt;javascript&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    alpha: 1,&lt;br /&gt;
    beta: [&lt;br /&gt;
       &amp;quot;x&amp;quot;,&lt;br /&gt;
       &amp;quot;y&amp;quot;,&lt;br /&gt;
       &amp;quot;z&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    gamma: {&lt;br /&gt;
       a: 3.2,&lt;br /&gt;
       b: true&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/javascript&amp;gt;&lt;br /&gt;
The following sequence could be used:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
string gamma_value = llList2Json( JSON_OBJECT, [ &amp;quot;a&amp;quot;, 3.2, &amp;quot;b&amp;quot;, TRUE ] );&lt;br /&gt;
string beta_value  = llList2Json( JSON_ARRAY, [ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ] );&lt;br /&gt;
string value       = llList2Json( JSON_OBJECT,[ &amp;quot;alpha&amp;quot;, 1, &amp;quot;beta&amp;quot;, beta_value, &amp;quot;gamma&amp;quot;, gamma_value ] );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or the equivalent without the intermediate variables:&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
string value =&lt;br /&gt;
    llList2Json( JSON_OBJECT,&lt;br /&gt;
        [&amp;quot;alpha&amp;quot;, 1,&lt;br /&gt;
         &amp;quot;beta&amp;quot;, llList2Json( JSON_ARRAY, [ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ] ),&lt;br /&gt;
         &amp;quot;gamma&amp;quot;, llList2Json( JSON_OBJECT, [ &amp;quot;a&amp;quot;, 3.2, &amp;quot;b&amp;quot;, TRUE ] )]&lt;br /&gt;
    );&lt;br /&gt;
&amp;lt;/lsl&amp;gt;&lt;/div&gt;</summary>
		<author><name>Gistya Eusebio</name></author>
	</entry>
	<entry>
		<id>https://wiki.secondlife.com/w/index.php?title=Json_usage_in_LSL&amp;diff=1179325</id>
		<title>Json usage in LSL</title>
		<link rel="alternate" type="text/html" href="https://wiki.secondlife.com/w/index.php?title=Json_usage_in_LSL&amp;diff=1179325"/>
		<updated>2013-06-19T17:04:16Z</updated>

		<summary type="html">&lt;p&gt;Gistya Eusebio: /* Specifying Json Elements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{LSL Header|lm=*}}{{LSLC|}}{{LSLC|JSON|*Json usage in LSL}}&lt;br /&gt;
==Type Conversions==&lt;br /&gt;
&lt;br /&gt;
Json has native representation for:&lt;br /&gt;
* numbers - directly mappable to LSL Integer and Float (json numbers without a decimal point are assumed to be Integers, those with a decimal point are Floats)&lt;br /&gt;
* strings - identical to LSL [[String]]&lt;br /&gt;
* arrays - a list of values of any type: directly analogous to an LSL [[List]]&lt;br /&gt;
* objects - represented in LSL as a strided list of name/value pairs (see below re: values)&lt;br /&gt;
* the constants &#039;true&#039; and &#039;false&#039; - directly mapped to and from the LSL constants [[JSON_TRUE]] and [[JSON_FALSE]]&lt;br /&gt;
* the constant &#039;null&#039; - directly mapped to and from the LSL constant [[JSON_NULL]]&lt;br /&gt;
* All other LSL types (Key, Rotation, and Vector) are implicitly converted to their string representation when converting to Json; when converting from Json to LSL, these values are returned as String values, so the script must explicitly convert using the existing conversion methods.&lt;br /&gt;
&lt;br /&gt;
==New LSL Methods==&lt;br /&gt;
===Specifying Json Elements===&lt;br /&gt;
&lt;br /&gt;
[[llJsonGetValue]], [[llJsonValueType]] and [[llJsonSetValue]] each take the same first two arguments:&lt;br /&gt;
  1. a JSON value in the form of a [[String|string]], and   &lt;br /&gt;
  2. a set of specifiers in the form of a [[List|list]].&lt;br /&gt;
[[llJsonSetValue]] additionally takes a third an argument: &lt;br /&gt;
  3. a JSON value in the form of a [[String|string]]. &lt;br /&gt;
&lt;br /&gt;
To understand specifiers one must generally understand that JSON data is structured in a [http://en.wikipedia.org/wiki/Nested_set_model nested set model]. LSL&#039;s built-in JSON parser uses the supplied &amp;quot;specifiers&amp;quot; list to perform [http://en.wikipedia.org/wiki/Tree_traversal tree traversal] on the nodes of the supplied JSON [http://en.wikipedia.org/wiki/Tree_(data_structure) tree data structure]. A JSON tree may be visualized as a set of hierarchical levels of parents and children. Each level is contained within &#039;&#039;&#039;curly braces {for objects, which are lists of members, that are defined as key-value pairs}&#039;&#039;&#039; or &#039;&#039;&#039;square braces [for arrays of elements, that are defined as single values]&#039;&#039;&#039;. When JSON is presented in a human-readable, it is traditionally formatted such that the first parent level of organization is indented farthest to the left, and each more deeply-nested child level of organization is indented farther and farther to the right. The left-most level of nodes have no parents, only children. They begin with the very first member that appears after the initial &amp;quot;{&amp;quot; character of the JSON string (if it starts as an object), or the first element that appears after the initial &amp;quot;[&amp;quot; character (if it starts as an array). A node is considered as being a parent only if it has a non-null JSON object or array as its value -- and if a node has no value, then its value is considered to be &amp;quot;null&amp;quot; (strings &amp;quot;{}&amp;quot; or &amp;quot;[]&amp;quot; or &amp;quot;&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
With that parent-child tree data structure in mind, the specifiers list that you supply in the above function tells tells LSL&#039;s JSON parser how to [http://en.wikipedia.org/wiki/Tree_(data_structure)#Traversal_methods walk the tree] of the JSON data that you have supplied with the first argument of the function. The first specifier in the list tells the LSL JSON parser which node to walk to first. The next specifier tells it which of that node&#039;s children to walk to. Once the LSL parser has &amp;quot;walked&amp;quot; to the last destination node specified by your list of specifiers, it will then perform the function on the JSON value that it finds there. &lt;br /&gt;
&lt;br /&gt;
If, anywhere along the line, any of the specified nodes do not exist, [[llJsonGetValue]] and [[llJsonValueType]] will almost always return [[JSON_INVALID]]. However there is a rare exception: if the specifiers list leads to a node that has no characters in its JSON string value, no matter what follows that &amp;quot;null-value node&amp;quot; in the specifiers list, JSON_NULL will be returned instead of JSON_INVALID -- even though, obviously, none of the following specifiers exist. For example, for the example object {&amp;quot;parent&amp;quot;:,} llJsonGetValue(example,[&amp;quot;parent&amp;quot;]) will return JSON_NULL, as will llJsonGetValue(example,[&amp;quot;parent&amp;quot;,&amp;quot;child that doesn&#039;t exist&amp;quot;,&amp;quot;etc.&amp;quot;]). Another example: a specifier pointing to any element of a valid array such as {&amp;quot;parent&amp;quot;:[ , ,  , , ]} will return JSON_NULL anywhere there is no JSON value specified at given position in the array; in this case llJsonGetValue(example,[&amp;quot;parent&amp;quot;,2]) returns JSON_NULL, as does llJsonGetValue(example,[&amp;quot;parent&amp;quot;,1,&amp;quot;child that does not exist&amp;quot;,&amp;quot;etc.&amp;quot;]). These rare scenarios may be useful in determining valid JSON paths for the setter: in all the scenarios where JSON_NULL is returned, the same set of specifiers is able to be used for [[llJsonSetValue]] -- whereas if JSON_INVALID is returned, there is no guarantee the setter won&#039;t return an error.&lt;br /&gt;
&lt;br /&gt;
For llJsonGetValue(), if a JSON value is present, it will be returned by the function. The value may an object that contains no valid JSON data, so be careful. Such an object will be deemed a JSON_OBJECT by llGetJsonType(), even if its contents are not valid JSON. Therefore it&#039;s always best to check the llJsonType() of any specified value to make sure it&#039;s valid before using the information in your script. &lt;br /&gt;
&lt;br /&gt;
The specifiers list may only consist of strings/keys (for object member keys), and integers (for array element positions), which define a path to the desired value in a JSON compound object.&lt;br /&gt;
&lt;br /&gt;
* An empty list specifies the entire Json value.&lt;br /&gt;
* If the list is not empty, each element of the list is used to select the element at the same level of nesting in the Json value:&lt;br /&gt;
** if the specifier list element is a string, then the corresponding element in the json value must be an object and the list element selects the value whose Json name exactly matches the string.&lt;br /&gt;
** if the specifier list element is an integer, then the corresponding element in the json value must be an array and the list element is used as a zero-based index into the Json array.&lt;br /&gt;
* Additionally llJsonSetValue accepts [[JSON_APPEND]] as a specifier to indicate appending the value to the end of the array at that level.&lt;br /&gt;
&lt;br /&gt;
For example, given the json value:&lt;br /&gt;
&amp;lt;javascript&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    alpha: 1,&lt;br /&gt;
    beta: [&lt;br /&gt;
       &amp;quot;x&amp;quot;,&lt;br /&gt;
       &amp;quot;y&amp;quot;,&lt;br /&gt;
       &amp;quot;z&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    gamma: {&lt;br /&gt;
       &amp;quot;a&amp;quot;: 3.2,&lt;br /&gt;
       &amp;quot;b&amp;quot;: true&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/javascript&amp;gt;&lt;br /&gt;
the contents of the string returned would be:&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;alpha&amp;quot; ] )        ⇒    1&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;beta&amp;quot; ] )         ⇒    [ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ]&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;beta&amp;quot;, 2 ] )      ⇒    z&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;gamma&amp;quot;, &amp;quot;a&amp;quot; ] )   ⇒    3.2&lt;br /&gt;
&amp;lt;/lsl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
llJsonSetValue(string json, list specifiers, string value_to_set) will force the resulting JSON to conform with the specifiers supplied, as long as the specified path is traversable.&lt;br /&gt;
&lt;br /&gt;
==Json Interrogation and Validation==&lt;br /&gt;
&lt;br /&gt;
To determine the type of a json value:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;lsl&amp;gt;string type = llJsonValueType( string json, list specifiers );&amp;lt;/lsl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:returns one of several following special constants (see table below). Each constant has a name, JSON_XXXX, which unlike most LSL constants is not an integer—instead, it&#039;s a single-character string. The single character is not printable but has a specific escape value (if run through llEscapeURL) in the range of  %EF%B7%90–97. The below table shows each constant&#039;s invocation and escape code:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Contant !! Escape value&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_INVALID]] || %EF%B7%90&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_OBJECT]] || %EF%B7%91&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_ARRAY]] || %EF%B7%92&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_NUMBER]] || %EF%B7%93&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_STRING]] || %EF%B7%94&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_NULL]] || %EF%B7%95&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_TRUE]] || %EF%B7%96&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_FALSE]] || %EF%B7%97&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Json to LSL Conversion==&lt;br /&gt;
&lt;br /&gt;
To directly extract a Json value to an LSL string:&lt;br /&gt;
&lt;br /&gt;
 string value = llJsonGetValue( string json, list specifiers );&lt;br /&gt;
* &#039;&#039;json&#039;&#039; is a string containing a valid json array or object value&lt;br /&gt;
* &#039;&#039;specifiers&#039;&#039; is a list of specifiers (see Specifying Json Elements)&lt;br /&gt;
* returns a json string&lt;br /&gt;
* if the specifiers do not indicate a value that exists in the input, [[JSON_INVALID]] is returned&lt;br /&gt;
&lt;br /&gt;
To convert a json compound value (either an array or an object) to an LSL List:&lt;br /&gt;
&lt;br /&gt;
 list values = llJson2List( string json );&lt;br /&gt;
* &#039;&#039;json&#039;&#039; is a string containing a valid json array or object value&lt;br /&gt;
* If the string in json is not a valid json object or array a list with a single item matching the conversion above is returned.&lt;br /&gt;
&lt;br /&gt;
==Recursive Parsing==&lt;br /&gt;
&lt;br /&gt;
Since any value in a Json array or object may be any arbitrary type, including an array or object, the parsing methods must handle nested values.  Nested arrays or objects are not converted, but remain LSL String values.  If an LSL script needs to use the components in such a nested value, it must explicitly pass that string to the appropriate method.  For example, the following json value is passed to llJson2List:&lt;br /&gt;
&amp;lt;javascript&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    alpha: 1,&lt;br /&gt;
    beta: [&lt;br /&gt;
       &amp;quot;x&amp;quot;,&lt;br /&gt;
       &amp;quot;y&amp;quot;,&lt;br /&gt;
       &amp;quot;z&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    gamma: {&lt;br /&gt;
       a: 3.2,&lt;br /&gt;
       b: true&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/javascript&amp;gt;&lt;br /&gt;
The result would be an LSL list with a stride of 2: the first elements of the 3 strides would be &amp;quot;alpha&amp;quot;, &amp;quot;beta&amp;quot;, and &amp;quot;gamma&amp;quot;.  The second element of the first stride would be the integer 1, but the second elements of the other two strides would be LSL strings containing the json representation of the array &#039;[ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ]&#039; and object &#039;{ a: 3.2, b: true }&#039; respectively.&lt;br /&gt;
&lt;br /&gt;
==LSL to Json==&lt;br /&gt;
&lt;br /&gt;
To convert a list to json:&lt;br /&gt;
 string json = llList2Json( string type, list values );&lt;br /&gt;
* &#039;&#039;type&#039;&#039; must be either [[JSON_ARRAY]] or [[JSON_OBJECT]]&lt;br /&gt;
* &#039;&#039;values&#039;&#039; is the list to be converted to json.&lt;br /&gt;
&lt;br /&gt;
:Produces an LSL String containing a Json compound value, either an array or an object depending on type, containing the values in the input list.  &lt;br /&gt;
&lt;br /&gt;
:If type is [[JSON_ARRAY]], the list may contain values of any LSL type; they are converted as described in Type Conversions above.  &lt;br /&gt;
&lt;br /&gt;
:If type is [[JSON_OBJECT]], the list must have a stride of 2.  The first value of each stride must be a string.  The second value of each stride may be any LSL type, and are converted as described in Type Conversions above. [[JSON_INVALID] is returned if the stride is not 2.&lt;br /&gt;
&lt;br /&gt;
:[[JSON_INVALID]] is returned if any other string or json type is specified as the type.&lt;br /&gt;
&lt;br /&gt;
To directly set a Json value within a string:&lt;br /&gt;
&lt;br /&gt;
 string jsonresult = llJsonSetValue( string json, list specifiers, string value );&lt;br /&gt;
* &#039;&#039;json&#039;&#039; is a string containing a valid json array or object value&lt;br /&gt;
* &#039;&#039;specifiers&#039;&#039; is a list of specifiers (see [[#Specifying Json Elements]])&lt;br /&gt;
* &#039;&#039;value&#039;&#039; the value to be inserted into the specified place in json&lt;br /&gt;
* Returns the newly modified json string&lt;br /&gt;
&lt;br /&gt;
:The only failure mode for llJsonSetValue is if an array index is specified in specifiers that is negative (but not [[JSON_APPEND]]) or more greater than the list size. In all other cases the json is modified so that the set can succeed. For example if an integer is specified for a level that is an object, the object will be removed completely and replaced with an array. If the object key does not exist it will be added, and JSON_APPEND or an index one larger than the last item in an array can be used to append to an array. These features are to allow building a Json string with llJsonSetValue.&lt;br /&gt;
&lt;br /&gt;
==Recursive Construction of Compound Json Values==&lt;br /&gt;
&lt;br /&gt;
Since LSL does not support nested lists, the construction method may only be used to convert a single level; to create a Json array or object whose values are nested arrays or objects, the LSL script must first construct the nested values and then pass those values as strings to another construction method call.  For example, to construct the Json value:&lt;br /&gt;
&amp;lt;javascript&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    alpha: 1,&lt;br /&gt;
    beta: [&lt;br /&gt;
       &amp;quot;x&amp;quot;,&lt;br /&gt;
       &amp;quot;y&amp;quot;,&lt;br /&gt;
       &amp;quot;z&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    gamma: {&lt;br /&gt;
       a: 3.2,&lt;br /&gt;
       b: true&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/javascript&amp;gt;&lt;br /&gt;
The following sequence could be used:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
string gamma_value = llList2Json( JSON_OBJECT, [ &amp;quot;a&amp;quot;, 3.2, &amp;quot;b&amp;quot;, TRUE ] );&lt;br /&gt;
string beta_value  = llList2Json( JSON_ARRAY, [ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ] );&lt;br /&gt;
string value       = llList2Json( JSON_OBJECT,[ &amp;quot;alpha&amp;quot;, 1, &amp;quot;beta&amp;quot;, beta_value, &amp;quot;gamma&amp;quot;, gamma_value ] );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or the equivalent without the intermediate variables:&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
string value =&lt;br /&gt;
    llList2Json( JSON_OBJECT,&lt;br /&gt;
        [&amp;quot;alpha&amp;quot;, 1,&lt;br /&gt;
         &amp;quot;beta&amp;quot;, llList2Json( JSON_ARRAY, [ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ] ),&lt;br /&gt;
         &amp;quot;gamma&amp;quot;, llList2Json( JSON_OBJECT, [ &amp;quot;a&amp;quot;, 3.2, &amp;quot;b&amp;quot;, TRUE ] )]&lt;br /&gt;
    );&lt;br /&gt;
&amp;lt;/lsl&amp;gt;&lt;/div&gt;</summary>
		<author><name>Gistya Eusebio</name></author>
	</entry>
	<entry>
		<id>https://wiki.secondlife.com/w/index.php?title=Json_usage_in_LSL&amp;diff=1179324</id>
		<title>Json usage in LSL</title>
		<link rel="alternate" type="text/html" href="https://wiki.secondlife.com/w/index.php?title=Json_usage_in_LSL&amp;diff=1179324"/>
		<updated>2013-06-19T17:03:31Z</updated>

		<summary type="html">&lt;p&gt;Gistya Eusebio: Explaining the JSON functions in much gretaer depth&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{LSL Header|lm=*}}{{LSLC|}}{{LSLC|JSON|*Json usage in LSL}}&lt;br /&gt;
==Type Conversions==&lt;br /&gt;
&lt;br /&gt;
Json has native representation for:&lt;br /&gt;
* numbers - directly mappable to LSL Integer and Float (json numbers without a decimal point are assumed to be Integers, those with a decimal point are Floats)&lt;br /&gt;
* strings - identical to LSL [[String]]&lt;br /&gt;
* arrays - a list of values of any type: directly analogous to an LSL [[List]]&lt;br /&gt;
* objects - represented in LSL as a strided list of name/value pairs (see below re: values)&lt;br /&gt;
* the constants &#039;true&#039; and &#039;false&#039; - directly mapped to and from the LSL constants [[JSON_TRUE]] and [[JSON_FALSE]]&lt;br /&gt;
* the constant &#039;null&#039; - directly mapped to and from the LSL constant [[JSON_NULL]]&lt;br /&gt;
* All other LSL types (Key, Rotation, and Vector) are implicitly converted to their string representation when converting to Json; when converting from Json to LSL, these values are returned as String values, so the script must explicitly convert using the existing conversion methods.&lt;br /&gt;
&lt;br /&gt;
==New LSL Methods==&lt;br /&gt;
===Specifying Json Elements===&lt;br /&gt;
&lt;br /&gt;
[[llJsonGetValue]], [[llJsonValueType]] and [[llJsonSetValue]] each take the same first two arguments:&lt;br /&gt;
  1. a JSON value in the form of a [[String|string]], and   &lt;br /&gt;
  2. a set of specifiers in the form of a [[List|list]].&lt;br /&gt;
[[llJsonSetValue]] additionally takes a third an argument: &lt;br /&gt;
  3. a JSON value in the form of a [[String|string]]. &lt;br /&gt;
&lt;br /&gt;
To understand specifiers one must generally understand that JSON data is structured in a [http://en.wikipedia.org/wiki/Nested_set_model nested set model]. LSL&#039;s built-in JSON parser uses the supplied &amp;quot;specifiers&amp;quot; list to perform [http://en.wikipedia.org/wiki/Tree_traversal tree traversal] on the nodes of the supplied JSON data [http://en.wikipedia.org/wiki/Tree_(data_structure) tree data structure]. A JSON tree may be visualized as a set of hierarchical levels of parents and children. Each level is contained within &#039;&#039;&#039;curly braces {for objects, which are lists of members, that are defined as key-value pairs}&#039;&#039;&#039; or &#039;&#039;&#039;square braces [for arrays of elements, that are defined as single values]&#039;&#039;&#039;. When JSON is presented in a human-readable, it is traditionally formatted such that the first parent level of organization is indented farthest to the left, and each more deeply-nested child level of organization is indented farther and farther to the right. The left-most level of nodes have no parents, only children. They begin with the very first member that appears after the initial &amp;quot;{&amp;quot; character of the JSON string (if it starts as an object), or the first element that appears after the initial &amp;quot;[&amp;quot; character (if it starts as an array). A node is considered as being a parent only if it has a non-null JSON object or array as its value -- and if a node has no value, then its value is considered to be &amp;quot;null&amp;quot; (strings &amp;quot;{}&amp;quot; or &amp;quot;[]&amp;quot; or &amp;quot;&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
With that parent-child tree data structure in mind, the specifiers list that you supply in the above function tells tells LSL&#039;s JSON parser how to [http://en.wikipedia.org/wiki/Tree_(data_structure)#Traversal_methods walk the tree] of the JSON data that you have supplied with the first argument of the function. The first specifier in the list tells the LSL JSON parser which node to walk to first. The next specifier tells it which of that node&#039;s children to walk to. Once the LSL parser has &amp;quot;walked&amp;quot; to the last destination node specified by your list of specifiers, it will then perform the function on the JSON value that it finds there. &lt;br /&gt;
&lt;br /&gt;
If, anywhere along the line, any of the specified nodes do not exist, [[llJsonGetValue]] and [[llJsonValueType]] will almost always return [[JSON_INVALID]]. However there is a rare exception: if the specifiers list leads to a node that has no characters in its JSON string value, no matter what follows that &amp;quot;null-value node&amp;quot; in the specifiers list, JSON_NULL will be returned instead of JSON_INVALID -- even though, obviously, none of the following specifiers exist. For example, for the example object {&amp;quot;parent&amp;quot;:,} llJsonGetValue(example,[&amp;quot;parent&amp;quot;]) will return JSON_NULL, as will llJsonGetValue(example,[&amp;quot;parent&amp;quot;,&amp;quot;child that doesn&#039;t exist&amp;quot;,&amp;quot;etc.&amp;quot;]). Another example: a specifier pointing to any element of a valid array such as {&amp;quot;parent&amp;quot;:[ , ,  , , ]} will return JSON_NULL anywhere there is no JSON value specified at given position in the array; in this case llJsonGetValue(example,[&amp;quot;parent&amp;quot;,2]) returns JSON_NULL, as does llJsonGetValue(example,[&amp;quot;parent&amp;quot;,1,&amp;quot;child that does not exist&amp;quot;,&amp;quot;etc.&amp;quot;]). These rare scenarios may be useful in determining valid JSON paths for the setter: in all the scenarios where JSON_NULL is returned, the same set of specifiers is able to be used for [[llJsonSetValue]] -- whereas if JSON_INVALID is returned, there is no guarantee the setter won&#039;t return an error.&lt;br /&gt;
&lt;br /&gt;
For llJsonGetValue(), if a JSON value is present, it will be returned by the function. The value may an object that contains no valid JSON data, so be careful. Such an object will be deemed a JSON_OBJECT by llGetJsonType(), even if its contents are not valid JSON. Therefore it&#039;s always best to check the llJsonType() of any specified value to make sure it&#039;s valid before using the information in your script. &lt;br /&gt;
&lt;br /&gt;
The specifiers list may only consist of strings/keys (for object member keys), and integers (for array element positions), which define a path to the desired value in a JSON compound object.&lt;br /&gt;
&lt;br /&gt;
* An empty list specifies the entire Json value.&lt;br /&gt;
* If the list is not empty, each element of the list is used to select the element at the same level of nesting in the Json value:&lt;br /&gt;
** if the specifier list element is a string, then the corresponding element in the json value must be an object and the list element selects the value whose Json name exactly matches the string.&lt;br /&gt;
** if the specifier list element is an integer, then the corresponding element in the json value must be an array and the list element is used as a zero-based index into the Json array.&lt;br /&gt;
* Additionally llJsonSetValue accepts [[JSON_APPEND]] as a specifier to indicate appending the value to the end of the array at that level.&lt;br /&gt;
&lt;br /&gt;
For example, given the json value:&lt;br /&gt;
&amp;lt;javascript&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    alpha: 1,&lt;br /&gt;
    beta: [&lt;br /&gt;
       &amp;quot;x&amp;quot;,&lt;br /&gt;
       &amp;quot;y&amp;quot;,&lt;br /&gt;
       &amp;quot;z&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    gamma: {&lt;br /&gt;
       &amp;quot;a&amp;quot;: 3.2,&lt;br /&gt;
       &amp;quot;b&amp;quot;: true&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/javascript&amp;gt;&lt;br /&gt;
the contents of the string returned would be:&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;alpha&amp;quot; ] )        ⇒    1&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;beta&amp;quot; ] )         ⇒    [ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ]&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;beta&amp;quot;, 2 ] )      ⇒    z&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;gamma&amp;quot;, &amp;quot;a&amp;quot; ] )   ⇒    3.2&lt;br /&gt;
&amp;lt;/lsl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
llJsonSetValue(string json, list specifiers, string value_to_set) will force the resulting JSON to conform with the specifiers supplied, as long as the specified path is traversable.&lt;br /&gt;
&lt;br /&gt;
==Json Interrogation and Validation==&lt;br /&gt;
&lt;br /&gt;
To determine the type of a json value:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;lsl&amp;gt;string type = llJsonValueType( string json, list specifiers );&amp;lt;/lsl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:returns one of several following special constants (see table below). Each constant has a name, JSON_XXXX, which unlike most LSL constants is not an integer—instead, it&#039;s a single-character string. The single character is not printable but has a specific escape value (if run through llEscapeURL) in the range of  %EF%B7%90–97. The below table shows each constant&#039;s invocation and escape code:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Contant !! Escape value&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_INVALID]] || %EF%B7%90&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_OBJECT]] || %EF%B7%91&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_ARRAY]] || %EF%B7%92&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_NUMBER]] || %EF%B7%93&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_STRING]] || %EF%B7%94&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_NULL]] || %EF%B7%95&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_TRUE]] || %EF%B7%96&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_FALSE]] || %EF%B7%97&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Json to LSL Conversion==&lt;br /&gt;
&lt;br /&gt;
To directly extract a Json value to an LSL string:&lt;br /&gt;
&lt;br /&gt;
 string value = llJsonGetValue( string json, list specifiers );&lt;br /&gt;
* &#039;&#039;json&#039;&#039; is a string containing a valid json array or object value&lt;br /&gt;
* &#039;&#039;specifiers&#039;&#039; is a list of specifiers (see Specifying Json Elements)&lt;br /&gt;
* returns a json string&lt;br /&gt;
* if the specifiers do not indicate a value that exists in the input, [[JSON_INVALID]] is returned&lt;br /&gt;
&lt;br /&gt;
To convert a json compound value (either an array or an object) to an LSL List:&lt;br /&gt;
&lt;br /&gt;
 list values = llJson2List( string json );&lt;br /&gt;
* &#039;&#039;json&#039;&#039; is a string containing a valid json array or object value&lt;br /&gt;
* If the string in json is not a valid json object or array a list with a single item matching the conversion above is returned.&lt;br /&gt;
&lt;br /&gt;
==Recursive Parsing==&lt;br /&gt;
&lt;br /&gt;
Since any value in a Json array or object may be any arbitrary type, including an array or object, the parsing methods must handle nested values.  Nested arrays or objects are not converted, but remain LSL String values.  If an LSL script needs to use the components in such a nested value, it must explicitly pass that string to the appropriate method.  For example, the following json value is passed to llJson2List:&lt;br /&gt;
&amp;lt;javascript&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    alpha: 1,&lt;br /&gt;
    beta: [&lt;br /&gt;
       &amp;quot;x&amp;quot;,&lt;br /&gt;
       &amp;quot;y&amp;quot;,&lt;br /&gt;
       &amp;quot;z&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    gamma: {&lt;br /&gt;
       a: 3.2,&lt;br /&gt;
       b: true&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/javascript&amp;gt;&lt;br /&gt;
The result would be an LSL list with a stride of 2: the first elements of the 3 strides would be &amp;quot;alpha&amp;quot;, &amp;quot;beta&amp;quot;, and &amp;quot;gamma&amp;quot;.  The second element of the first stride would be the integer 1, but the second elements of the other two strides would be LSL strings containing the json representation of the array &#039;[ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ]&#039; and object &#039;{ a: 3.2, b: true }&#039; respectively.&lt;br /&gt;
&lt;br /&gt;
==LSL to Json==&lt;br /&gt;
&lt;br /&gt;
To convert a list to json:&lt;br /&gt;
 string json = llList2Json( string type, list values );&lt;br /&gt;
* &#039;&#039;type&#039;&#039; must be either [[JSON_ARRAY]] or [[JSON_OBJECT]]&lt;br /&gt;
* &#039;&#039;values&#039;&#039; is the list to be converted to json.&lt;br /&gt;
&lt;br /&gt;
:Produces an LSL String containing a Json compound value, either an array or an object depending on type, containing the values in the input list.  &lt;br /&gt;
&lt;br /&gt;
:If type is [[JSON_ARRAY]], the list may contain values of any LSL type; they are converted as described in Type Conversions above.  &lt;br /&gt;
&lt;br /&gt;
:If type is [[JSON_OBJECT]], the list must have a stride of 2.  The first value of each stride must be a string.  The second value of each stride may be any LSL type, and are converted as described in Type Conversions above. [[JSON_INVALID] is returned if the stride is not 2.&lt;br /&gt;
&lt;br /&gt;
:[[JSON_INVALID]] is returned if any other string or json type is specified as the type.&lt;br /&gt;
&lt;br /&gt;
To directly set a Json value within a string:&lt;br /&gt;
&lt;br /&gt;
 string jsonresult = llJsonSetValue( string json, list specifiers, string value );&lt;br /&gt;
* &#039;&#039;json&#039;&#039; is a string containing a valid json array or object value&lt;br /&gt;
* &#039;&#039;specifiers&#039;&#039; is a list of specifiers (see [[#Specifying Json Elements]])&lt;br /&gt;
* &#039;&#039;value&#039;&#039; the value to be inserted into the specified place in json&lt;br /&gt;
* Returns the newly modified json string&lt;br /&gt;
&lt;br /&gt;
:The only failure mode for llJsonSetValue is if an array index is specified in specifiers that is negative (but not [[JSON_APPEND]]) or more greater than the list size. In all other cases the json is modified so that the set can succeed. For example if an integer is specified for a level that is an object, the object will be removed completely and replaced with an array. If the object key does not exist it will be added, and JSON_APPEND or an index one larger than the last item in an array can be used to append to an array. These features are to allow building a Json string with llJsonSetValue.&lt;br /&gt;
&lt;br /&gt;
==Recursive Construction of Compound Json Values==&lt;br /&gt;
&lt;br /&gt;
Since LSL does not support nested lists, the construction method may only be used to convert a single level; to create a Json array or object whose values are nested arrays or objects, the LSL script must first construct the nested values and then pass those values as strings to another construction method call.  For example, to construct the Json value:&lt;br /&gt;
&amp;lt;javascript&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    alpha: 1,&lt;br /&gt;
    beta: [&lt;br /&gt;
       &amp;quot;x&amp;quot;,&lt;br /&gt;
       &amp;quot;y&amp;quot;,&lt;br /&gt;
       &amp;quot;z&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    gamma: {&lt;br /&gt;
       a: 3.2,&lt;br /&gt;
       b: true&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/javascript&amp;gt;&lt;br /&gt;
The following sequence could be used:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
string gamma_value = llList2Json( JSON_OBJECT, [ &amp;quot;a&amp;quot;, 3.2, &amp;quot;b&amp;quot;, TRUE ] );&lt;br /&gt;
string beta_value  = llList2Json( JSON_ARRAY, [ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ] );&lt;br /&gt;
string value       = llList2Json( JSON_OBJECT,[ &amp;quot;alpha&amp;quot;, 1, &amp;quot;beta&amp;quot;, beta_value, &amp;quot;gamma&amp;quot;, gamma_value ] );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or the equivalent without the intermediate variables:&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
string value =&lt;br /&gt;
    llList2Json( JSON_OBJECT,&lt;br /&gt;
        [&amp;quot;alpha&amp;quot;, 1,&lt;br /&gt;
         &amp;quot;beta&amp;quot;, llList2Json( JSON_ARRAY, [ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ] ),&lt;br /&gt;
         &amp;quot;gamma&amp;quot;, llList2Json( JSON_OBJECT, [ &amp;quot;a&amp;quot;, 3.2, &amp;quot;b&amp;quot;, TRUE ] )]&lt;br /&gt;
    );&lt;br /&gt;
&amp;lt;/lsl&amp;gt;&lt;/div&gt;</summary>
		<author><name>Gistya Eusebio</name></author>
	</entry>
	<entry>
		<id>https://wiki.secondlife.com/w/index.php?title=Json_usage_in_LSL&amp;diff=1179164</id>
		<title>Json usage in LSL</title>
		<link rel="alternate" type="text/html" href="https://wiki.secondlife.com/w/index.php?title=Json_usage_in_LSL&amp;diff=1179164"/>
		<updated>2013-06-13T09:31:37Z</updated>

		<summary type="html">&lt;p&gt;Gistya Eusebio: /* Specifying Json Elements */ explaining how the JSON_NULL type works&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{LSL Header|lm=*}}{{LSLC|}}{{LSLC|JSON|*Json usage in LSL}}&lt;br /&gt;
==Type Conversions==&lt;br /&gt;
&lt;br /&gt;
Json has native representation for:&lt;br /&gt;
* numbers - directly mappable to LSL Integer and Float (json numbers without a decimal point are assumed to be Integers, those with a decimal point are Floats)&lt;br /&gt;
* strings - identical to LSL [[String]]&lt;br /&gt;
* arrays - a list of values of any type: directly analogous to an LSL [[List]]&lt;br /&gt;
* objects - represented in LSL as a strided list of name/value pairs (see below re: values)&lt;br /&gt;
* the constants &#039;true&#039; and &#039;false&#039; - directly mapped to and from the LSL constants [[JSON_TRUE]] and [[JSON_FALSE]]&lt;br /&gt;
* the constant &#039;null&#039; - directly mapped to and from the LSL constant [[JSON_NULL]]&lt;br /&gt;
* All other LSL types (Key, Rotation, and Vector) are implicitly converted to their string representation when converting to Json; when converting from Json to LSL, these values are returned as String values, so the script must explicitly convert using the existing conversion methods.&lt;br /&gt;
&lt;br /&gt;
==New LSL Methods==&lt;br /&gt;
===Specifying Json Elements===&lt;br /&gt;
&lt;br /&gt;
[[llJsonGetValue]], [[llJsonValueType]] and [[llJsonSetValue]] take a Json value in an LSL string, and an LSL list of specifiers. The specifiers are a list consisting only of strings (or keys) and integers, which define a path to the desired value in a Json compound object.&lt;br /&gt;
&lt;br /&gt;
* An empty list specifies the entire Json value.&lt;br /&gt;
* If the list is not empty, each element of the list is used to select the element at the same level of nesting in the Json value:&lt;br /&gt;
** if the specifier list element is a string, then the corresponding element in the json value must be an object and the list element selects the value whose Json name exactly matches the string.&lt;br /&gt;
** if the specifier list element is an integer, then the corresponding element in the json value must be an array and the list element is used as a zero-based index into the Json array.&lt;br /&gt;
* Additionally llJsonSetValue accepts [[JSON_APPEND]] as a specifier to indicate appending the value to the end of the array at that level.&lt;br /&gt;
&lt;br /&gt;
For example, given the json value:&lt;br /&gt;
&amp;lt;javascript&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    alpha: 1,&lt;br /&gt;
    beta: [&lt;br /&gt;
       &amp;quot;x&amp;quot;,&lt;br /&gt;
       &amp;quot;y&amp;quot;,&lt;br /&gt;
       &amp;quot;z&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    gamma: {&lt;br /&gt;
       &amp;quot;a&amp;quot;: 3.2,&lt;br /&gt;
       &amp;quot;b&amp;quot;: true&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/javascript&amp;gt;&lt;br /&gt;
the contents of the string returned would be:&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;alpha&amp;quot; ] )        ⇒    1&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;beta&amp;quot; ] )         ⇒    [ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ]&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;beta&amp;quot;, 2 ] )      ⇒    z&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;gamma&amp;quot;, &amp;quot;a&amp;quot; ] )   ⇒    3.2&lt;br /&gt;
&amp;lt;/lsl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For llJsonGetValue and llJsonValueType If the specifiers do not specify a valid path in the given json value, the constant [[JSON_INVALID]] is returned, unless the specifiers reduce the JSON string to nothing (not even brackets), in which case JSON_NULL is returned. For instance for:&lt;br /&gt;
{&amp;quot;foo&amp;quot;: {&amp;quot;bar&amp;quot;:, &amp;quot;foo&amp;quot;: {&amp;quot;bar&amp;quot;:&amp;quot;foo&amp;quot;} } }&lt;br /&gt;
the JSON type of specifier [&amp;quot;foo&amp;quot;,&amp;quot;bar&amp;quot;] is JSON_NULL as is [&amp;quot;foo&amp;quot;,&amp;quot;bar&amp;quot;,&amp;quot;anything&amp;quot;,&amp;quot;else&amp;quot;].&lt;br /&gt;
Meanwhile the JSON type of [&amp;quot;foo&amp;quot;,&amp;quot;foo&amp;quot;,&amp;quot;anything other than bar&amp;quot;] is JSON_INVALID. Also [&amp;quot;bar&amp;quot;,&amp;quot;anything&amp;quot;] etc.&lt;br /&gt;
&lt;br /&gt;
llJsonSetValue will force the resulting json to conform with the specifiers supplied.&lt;br /&gt;
&lt;br /&gt;
==Json Interrogation and Validation==&lt;br /&gt;
&lt;br /&gt;
To determine the type of a json value:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;lsl&amp;gt;string type = llJsonValueType( string json, list specifiers );&amp;lt;/lsl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:returns one of several following special constants (see table below). Each constant has a name, JSON_XXXX, which unlike most LSL constants is not an integer—instead, it&#039;s a single-character string. The single character is not printable but has a specific escape value (if run through llEscapeURL) in the range of  %EF%B7%90–97. The below table shows each constant&#039;s invocation and escape code:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Contant !! Escape value&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_INVALID]] || %EF%B7%90&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_OBJECT]] || %EF%B7%91&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_ARRAY]] || %EF%B7%92&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_NUMBER]] || %EF%B7%93&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_STRING]] || %EF%B7%94&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_NULL]] || %EF%B7%95&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_TRUE]] || %EF%B7%96&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_FALSE]] || %EF%B7%97&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Json to LSL Conversion==&lt;br /&gt;
&lt;br /&gt;
To directly extract a Json value to an LSL string:&lt;br /&gt;
&lt;br /&gt;
 string value = llJsonGetValue( string json, list specifiers );&lt;br /&gt;
* &#039;&#039;json&#039;&#039; is a string containing a valid json array or object value&lt;br /&gt;
* &#039;&#039;specifiers&#039;&#039; is a list of specifiers (see Specifying Json Elements)&lt;br /&gt;
* returns a json string&lt;br /&gt;
* if the specifiers do not indicate a value that exists in the input, [[JSON_INVALID]] is returned&lt;br /&gt;
&lt;br /&gt;
To convert a json compound value (either an array or an object) to an LSL List:&lt;br /&gt;
&lt;br /&gt;
 list values = llJson2List( string json );&lt;br /&gt;
* &#039;&#039;json&#039;&#039; is a string containing a valid json array or object value&lt;br /&gt;
* If the string in json is not a valid json object or array a list with a single item matching the conversion above is returned.&lt;br /&gt;
&lt;br /&gt;
==Recursive Parsing==&lt;br /&gt;
&lt;br /&gt;
Since any value in a Json array or object may be any arbitrary type, including an array or object, the parsing methods must handle nested values.  Nested arrays or objects are not converted, but remain LSL String values.  If an LSL script needs to use the components in such a nested value, it must explicitly pass that string to the appropriate method.  For example, the following json value is passed to llJson2List:&lt;br /&gt;
&amp;lt;javascript&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    alpha: 1,&lt;br /&gt;
    beta: [&lt;br /&gt;
       &amp;quot;x&amp;quot;,&lt;br /&gt;
       &amp;quot;y&amp;quot;,&lt;br /&gt;
       &amp;quot;z&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    gamma: {&lt;br /&gt;
       a: 3.2,&lt;br /&gt;
       b: true&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/javascript&amp;gt;&lt;br /&gt;
The result would be an LSL list with a stride of 2: the first elements of the 3 strides would be &amp;quot;alpha&amp;quot;, &amp;quot;beta&amp;quot;, and &amp;quot;gamma&amp;quot;.  The second element of the first stride would be the integer 1, but the second elements of the other two strides would be LSL strings containing the json representation of the array &#039;[ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ]&#039; and object &#039;{ a: 3.2, b: true }&#039; respectively.&lt;br /&gt;
&lt;br /&gt;
==LSL to Json==&lt;br /&gt;
&lt;br /&gt;
To convert a list to json:&lt;br /&gt;
 string json = llList2Json( string type, list values );&lt;br /&gt;
* &#039;&#039;type&#039;&#039; must be either [[JSON_ARRAY]] or [[JSON_OBJECT]]&lt;br /&gt;
* &#039;&#039;values&#039;&#039; is the list to be converted to json.&lt;br /&gt;
&lt;br /&gt;
:Produces an LSL String containing a Json compound value, either an array or an object depending on type, containing the values in the input list.  &lt;br /&gt;
&lt;br /&gt;
:If type is [[JSON_ARRAY]], the list may contain values of any LSL type; they are converted as described in Type Conversions above.  &lt;br /&gt;
&lt;br /&gt;
:If type is [[JSON_OBJECT]], the list must have a stride of 2.  The first value of each stride must be a string.  The second value of each stride may be any LSL type, and are converted as described in Type Conversions above. [[JSON_INVALID] is returned if the stride is not 2.&lt;br /&gt;
&lt;br /&gt;
:[[JSON_INVALID]] is returned if any other string or json type is specified as the type.&lt;br /&gt;
&lt;br /&gt;
To directly set a Json value within a string:&lt;br /&gt;
&lt;br /&gt;
 string jsonresult = llJsonSetValue( string json, list specifiers, string value );&lt;br /&gt;
* &#039;&#039;json&#039;&#039; is a string containing a valid json array or object value&lt;br /&gt;
* &#039;&#039;specifiers&#039;&#039; is a list of specifiers (see [[#Specifying Json Elements]])&lt;br /&gt;
* &#039;&#039;value&#039;&#039; the value to be inserted into the specified place in json&lt;br /&gt;
* Returns the newly modified json string&lt;br /&gt;
&lt;br /&gt;
:The only failure mode for llJsonSetValue is if an array index is specified in specifiers that is negative (but not [[JSON_APPEND]]) or more greater than the list size. In all other cases the json is modified so that the set can succeed. For example if an integer is specified for a level that is an object, the object will be removed completely and replaced with an array. If the object key does not exist it will be added, and JSON_APPEND or an index one larger than the last item in an array can be used to append to an array. These features are to allow building a Json string with llJsonSetValue.&lt;br /&gt;
&lt;br /&gt;
==Recursive Construction of Compound Json Values==&lt;br /&gt;
&lt;br /&gt;
Since LSL does not support nested lists, the construction method may only be used to convert a single level; to create a Json array or object whose values are nested arrays or objects, the LSL script must first construct the nested values and then pass those values as strings to another construction method call.  For example, to construct the Json value:&lt;br /&gt;
&amp;lt;javascript&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    alpha: 1,&lt;br /&gt;
    beta: [&lt;br /&gt;
       &amp;quot;x&amp;quot;,&lt;br /&gt;
       &amp;quot;y&amp;quot;,&lt;br /&gt;
       &amp;quot;z&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    gamma: {&lt;br /&gt;
       a: 3.2,&lt;br /&gt;
       b: true&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/javascript&amp;gt;&lt;br /&gt;
The following sequence could be used:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
string gamma_value = llList2Json( JSON_OBJECT, [ &amp;quot;a&amp;quot;, 3.2, &amp;quot;b&amp;quot;, TRUE ] );&lt;br /&gt;
string beta_value  = llList2Json( JSON_ARRAY, [ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ] );&lt;br /&gt;
string value       = llList2Json( JSON_OBJECT,[ &amp;quot;alpha&amp;quot;, 1, &amp;quot;beta&amp;quot;, beta_value, &amp;quot;gamma&amp;quot;, gamma_value ] );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or the equivalent without the intermediate variables:&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
string value =&lt;br /&gt;
    llList2Json( JSON_OBJECT,&lt;br /&gt;
        [&amp;quot;alpha&amp;quot;, 1,&lt;br /&gt;
         &amp;quot;beta&amp;quot;, llList2Json( JSON_ARRAY, [ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ] ),&lt;br /&gt;
         &amp;quot;gamma&amp;quot;, llList2Json( JSON_OBJECT, [ &amp;quot;a&amp;quot;, 3.2, &amp;quot;b&amp;quot;, TRUE ] )]&lt;br /&gt;
    );&lt;br /&gt;
&amp;lt;/lsl&amp;gt;&lt;/div&gt;</summary>
		<author><name>Gistya Eusebio</name></author>
	</entry>
	<entry>
		<id>https://wiki.secondlife.com/w/index.php?title=Json_usage_in_LSL&amp;diff=1178958</id>
		<title>Json usage in LSL</title>
		<link rel="alternate" type="text/html" href="https://wiki.secondlife.com/w/index.php?title=Json_usage_in_LSL&amp;diff=1178958"/>
		<updated>2013-06-09T05:36:24Z</updated>

		<summary type="html">&lt;p&gt;Gistya Eusebio: added table showing the escape codes of the json type constants&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{LSL Header|lm=*}}{{LSLC|}}{{LSLC|JSON}}&lt;br /&gt;
==Type Conversions==&lt;br /&gt;
&lt;br /&gt;
Json has native representation for:&lt;br /&gt;
* numbers - directly mappable to LSL Integer and Float (json numbers without a decimal point are assumed to be Integers, those with a decimal point are Floats)&lt;br /&gt;
* strings - identical to LSL [[String]]&lt;br /&gt;
* arrays - a list of values of any type: directly analogous to an LSL [[List]]&lt;br /&gt;
* objects - represented in LSL as a strided list of name/value pairs (see below re: values)&lt;br /&gt;
* the constants &#039;true&#039; and &#039;false&#039; - directly mapped to and from the LSL constants [[JSON_TRUE]] and [[JSON_FALSE]]&lt;br /&gt;
* the constant &#039;null&#039; - directly mapped to and from the LSL constant [[JSON_NULL]]&lt;br /&gt;
* All other LSL types (Key, Rotation, and Vector) are implicitly converted to their string representation when converting to Json; when converting from Json to LSL, these values are returned as String values, so the script must explicitly convert using the existing conversion methods.&lt;br /&gt;
&lt;br /&gt;
==New LSL Methods==&lt;br /&gt;
===Specifying Json Elements===&lt;br /&gt;
&lt;br /&gt;
[[llJsonGetValue]], [[llJsonValueType]] and [[llJsonSetValue]] take a Json value in an LSL string, and an LSL list of specifiers. The specifiers are a list consisting only of strings (or keys) and integers, which define a path to the desired value in a Json compound object.&lt;br /&gt;
&lt;br /&gt;
* An empty list specifies the entire Json value.&lt;br /&gt;
* If the list is not empty, each element of the list is used to select the element at the same level of nesting in the Json value:&lt;br /&gt;
** if the specifier list element is a string, then the corresponding element in the json value must be an object and the list element selects the value whose Json name exactly matches the string.&lt;br /&gt;
** if the specifier list element is an integer, then the corresponding element in the json value must be an array and the list element is used as a zero-based index into the Json array.&lt;br /&gt;
* Additionally llJsonSetValue accepts [[JSON_APPEND]] as a specifier to indicate appending the value to the end of the array at that level.&lt;br /&gt;
&lt;br /&gt;
For example, given the json value:&lt;br /&gt;
&amp;lt;javascript&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    alpha: 1,&lt;br /&gt;
    beta: [&lt;br /&gt;
       &amp;quot;x&amp;quot;,&lt;br /&gt;
       &amp;quot;y&amp;quot;,&lt;br /&gt;
       &amp;quot;z&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    gamma: {&lt;br /&gt;
       &amp;quot;a&amp;quot;: 3.2,&lt;br /&gt;
       &amp;quot;b&amp;quot;: true&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/javascript&amp;gt;&lt;br /&gt;
the contents of the string returned would be:&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;alpha&amp;quot; ] )        ⇒    1&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;beta&amp;quot; ] )         ⇒    [ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ]&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;beta&amp;quot;, 2 ] )      ⇒    z&lt;br /&gt;
llJsonGetValue ( value, [ &amp;quot;gamma&amp;quot;, &amp;quot;a&amp;quot; ] )   ⇒    3.2&lt;br /&gt;
&amp;lt;/lsl&amp;gt;&lt;br /&gt;
For llJsonGetValue and llJsonValueType If the specifiers do not specify a valid path in the given json value, the constant [[JSON_INVALID]] is returned. llJsonSetValue will force the resulting json to conform with the specifiers supplied.&lt;br /&gt;
&lt;br /&gt;
==Json Interrogation and Validation==&lt;br /&gt;
&lt;br /&gt;
To determine the type of a json value:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;lsl&amp;gt;string type = llJsonValueType( string json, list specifiers );&amp;lt;/lsl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:returns one of several following special constants (see table below). Each constant has a name, JSON_XXXX, which unlike most LSL constants is not an integer—instead, it&#039;s a single-character string. The single character is not printable but has a specific escape value (if run through llEscapeURL) in the range of  %EF%B7%90–97. The below table shows each constant&#039;s invocation and escape code:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Contant !! Escape value&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_INVALID]] || %EF%B7%90&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_OBJECT]] || %EF%B7%91&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_ARRAY]] || %EF%B7%92&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_NUMBER]] || %EF%B7%93&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_STRING]] || %EF%B7%94&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_NULL]] || %EF%B7%95&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_TRUE]] || %EF%B7%96&lt;br /&gt;
|-&lt;br /&gt;
| [[JSON_FALSE]] || %EF%B7%97&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Json to LSL Conversion==&lt;br /&gt;
&lt;br /&gt;
To directly extract a Json value to an LSL string:&lt;br /&gt;
&lt;br /&gt;
 string value = llJsonGetValue( string json, list specifiers );&lt;br /&gt;
* &#039;&#039;json&#039;&#039; is a string containing a valid json array or object value&lt;br /&gt;
* &#039;&#039;specifiers&#039;&#039; is a list of specifiers (see Specifying Json Elements)&lt;br /&gt;
* returns a json string.&lt;br /&gt;
&lt;br /&gt;
To convert a json compound value (either an array or an object) to an LSL List:&lt;br /&gt;
&lt;br /&gt;
 list values = llJson2List( string json );&lt;br /&gt;
* &#039;&#039;json&#039;&#039; is a string containing a valid json array or object value&lt;br /&gt;
* If the string in json is not a valid json object or array a list with a single item matching the conversion above is returned.&lt;br /&gt;
&lt;br /&gt;
==Recursive Parsing==&lt;br /&gt;
&lt;br /&gt;
Since any value in a Json array or object may be any arbitrary type, including an array or object, the parsing methods must handle nested values.  Nested arrays or objects are not converted, but remain LSL String values.  If an LSL script needs to use the components in such a nested value, it must explicitly pass that string to the appropriate method.  For example, the following json value is passed to llJson2List:&lt;br /&gt;
&amp;lt;javascript&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    alpha: 1,&lt;br /&gt;
    beta: [&lt;br /&gt;
       &amp;quot;x&amp;quot;,&lt;br /&gt;
       &amp;quot;y&amp;quot;,&lt;br /&gt;
       &amp;quot;z&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    gamma: {&lt;br /&gt;
       a: 3.2,&lt;br /&gt;
       b: true&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/javascript&amp;gt;&lt;br /&gt;
The result would be an LSL list with a stride of 2: the first elements of the 3 strides would be &amp;quot;alpha&amp;quot;, &amp;quot;beta&amp;quot;, and &amp;quot;gamma&amp;quot;.  The second element of the first stride would be the integer 1, but the second elements of the other two strides would be LSL strings containing the json representation of the array &#039;[ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ]&#039; and object &#039;{ a: 3.2, b: true }&#039; respectively.&lt;br /&gt;
&lt;br /&gt;
==LSL to Json==&lt;br /&gt;
&lt;br /&gt;
To convert a list to json:&lt;br /&gt;
 string json = llList2Json( string type, list values );&lt;br /&gt;
* &#039;&#039;type&#039;&#039; must be either [[JSON_ARRAY]] or [[JSON_OBJECT]]&lt;br /&gt;
* &#039;&#039;values&#039;&#039; is the list to be converted to json.&lt;br /&gt;
&lt;br /&gt;
:Produces an LSL String containing a Json compound value, either an array or an object depending on type, containing the values in the input list.  &lt;br /&gt;
&lt;br /&gt;
:If type is [[JSON_ARRAY]], the list may contain values of any LSL type; they are converted as described in Type Conversions above.  &lt;br /&gt;
&lt;br /&gt;
:If type is [[JSON_OBJECT]], the list must have a stride of 2.  The first value of each stride must be a string.  The second value of each stride may be any LSL type, and are converted as described in Type Conversions above. [[JSON_INVALID] is returned if the stride is not 2.&lt;br /&gt;
&lt;br /&gt;
:[[JSON_INVALID]] is returned if any other string or json type is specified as the type.&lt;br /&gt;
&lt;br /&gt;
To directly set a Json value within a string:&lt;br /&gt;
&lt;br /&gt;
 string jsonresult = llJsonSetValue( string json, list specifiers, string value );&lt;br /&gt;
* &#039;&#039;json&#039;&#039; is a string containing a valid json array or object value&lt;br /&gt;
* &#039;&#039;specifiers&#039;&#039; is a list of specifiers (see Specifying Json Elements)&lt;br /&gt;
* &#039;&#039;value&#039;&#039; the value to be inserted into the specified place in json&lt;br /&gt;
* Returns the newly modified json string&lt;br /&gt;
&lt;br /&gt;
:The only failure mode for llJsonSetValue is if an array index is specified in specifiers that is negative (but not [[JSON_APPEND]]) or more greater than the list size. In all other cases the json is modified so that the set can succeed. For example if an integer is specified for a level that is an object, the object will be removed completely and replaced with an array. If the object key does not exist it will be added, and JSON_APPEND or an index one larger than the last item in an array can be used to append to an array. These features are to allow building a Json string with llJsonSetValue.&lt;br /&gt;
&lt;br /&gt;
==Recursive Construction of Compound Json Values==&lt;br /&gt;
&lt;br /&gt;
Since LSL does not support nested lists, the construction method may only be used to convert a single level; to create a Json array or object whose values are nested arrays or objects, the LSL script must first construct the nested values and then pass those values as strings to another construction method call.  For example, to construct the Json value:&lt;br /&gt;
&amp;lt;javascript&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    alpha: 1,&lt;br /&gt;
    beta: [&lt;br /&gt;
       &amp;quot;x&amp;quot;,&lt;br /&gt;
       &amp;quot;y&amp;quot;,&lt;br /&gt;
       &amp;quot;z&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    gamma: {&lt;br /&gt;
       a: 3.2,&lt;br /&gt;
       b: true&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/javascript&amp;gt;&lt;br /&gt;
The following sequence could be used:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
string gamma_value = llList2Json( JSON_OBJECT, [ &amp;quot;a&amp;quot;, 3.2, &amp;quot;b&amp;quot;, TRUE ] );&lt;br /&gt;
string beta_value  = llList2Json( JSON_ARRAY, [ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ] );&lt;br /&gt;
string value       = llList2Json( JSON_OBJECT,[ &amp;quot;alpha&amp;quot;, 1, &amp;quot;beta&amp;quot;, beta_value, &amp;quot;gamma&amp;quot;, gamma_value ] );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or the equivalent without the intermediate variables:&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
string value =&lt;br /&gt;
    llList2Json( JSON_OBJECT,&lt;br /&gt;
        [&amp;quot;alpha&amp;quot;, 1,&lt;br /&gt;
         &amp;quot;beta&amp;quot;, llList2Json( JSON_OBJECT, [ &amp;quot;a&amp;quot;, 3.2, &amp;quot;b&amp;quot;, TRUE ] ),&lt;br /&gt;
         &amp;quot;gamma&amp;quot;, llList2Json( JSON_ARRAY, [ &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot; ] )]&lt;br /&gt;
    );&lt;br /&gt;
&amp;lt;/lsl&amp;gt;&lt;/div&gt;</summary>
		<author><name>Gistya Eusebio</name></author>
	</entry>
	<entry>
		<id>https://wiki.secondlife.com/w/index.php?title=LlSHA1String&amp;diff=1178808</id>
		<title>LlSHA1String</title>
		<link rel="alternate" type="text/html" href="https://wiki.secondlife.com/w/index.php?title=LlSHA1String&amp;diff=1178808"/>
		<updated>2013-06-03T17:39:14Z</updated>

		<summary type="html">&lt;p&gt;Gistya Eusebio: corrected a typo in caveats&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{LSL_Function&lt;br /&gt;
|func_id=343|func_sleep=0.0|func_energy=10.0&lt;br /&gt;
|func=llSHA1String|return_type=string|p1_type=string|p1_name=src&lt;br /&gt;
|func_footnote&lt;br /&gt;
|func_desc&lt;br /&gt;
|return_text=of 40 hex characters that is the {{Wikipedia|SHA-1|SHA-1}} security hash of &#039;&#039;&#039;src&#039;&#039;&#039;.&lt;br /&gt;
|spec=LSL strings are stored in the UTF-8 format.&lt;br /&gt;
|caveats=There&#039;s no way to input a zero-byte value into this function, nor any byte value from 128-255, therefore it&#039;s currently broken for many purposes (like HMAC-SHA1). The reason is because LSL strings cannot have a unicode null character (U+0000) in them, and LSL has no escape code for the null character (many programming languages use \0 but LSL does not have this feature). llEscapeURL(&amp;quot;%00&amp;quot;) yields an empty string. As well, inside this function, each character with a Unicode integer value over U+0127 / 007F are dealt with in UTF-8 fashion: in the hex values, 0xC2 is appended to the byte value (hence 0x0080-0x00FF become 0xC280-0xC2FF inside the llSHA1String() routine). A JIRA has been filed for this.&lt;br /&gt;
|constants&lt;br /&gt;
|examples=&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
llSay(0, llSHA1String(&amp;quot;Hello, Avatar!&amp;quot;)); // returns 2E73318E547AF1B28CC0C96F95DDC9B1EE906B8D&lt;br /&gt;
&amp;lt;/lsl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Linux Example====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ echo -n &#039;Hello, Avatar!&#039; | openssl sha1&lt;br /&gt;
2E73318E547AF1B28CC0C96F95DDC9B1EE906B8D&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|helpers&lt;br /&gt;
|also_functions=&lt;br /&gt;
{{LSL DefineRow||[[llMD5String]]}}&lt;br /&gt;
|also_tests&lt;br /&gt;
|also_events&lt;br /&gt;
|also_articles=&lt;br /&gt;
{{LSL DefineRow||[[SHA-1]]}}&lt;br /&gt;
|notes&lt;br /&gt;
|deepnotes=&lt;br /&gt;
Prior to this, the only way to get the SHA-1 hash was to use the LSL SHA-1 port: [[SHA-1]]&lt;br /&gt;
|history=&lt;br /&gt;
*{{SVN|1291|rev=98903|trunk=*|anchor=file13|ver=1.21.5.97417|ser=1.24.9.98650}} Initial introduction.&lt;br /&gt;
*{{SVN|1298|rev=99021|branch=OpenAL|ver=1.21.5.97417|ser=1.24.9.98650|path=branches/openal/indra/lscript/lscript_library/lscript_library.cpp}} Integration into OpenAL branch.&lt;br /&gt;
|cat1=Hash&lt;br /&gt;
|cat2=Encoding&lt;br /&gt;
|cat3&lt;br /&gt;
|cat4&lt;br /&gt;
}}{{LSLC{{#var:lang}}|Encryption|llSHA1String}}&lt;/div&gt;</summary>
		<author><name>Gistya Eusebio</name></author>
	</entry>
	<entry>
		<id>https://wiki.secondlife.com/w/index.php?title=LlSHA1String&amp;diff=1178807</id>
		<title>LlSHA1String</title>
		<link rel="alternate" type="text/html" href="https://wiki.secondlife.com/w/index.php?title=LlSHA1String&amp;diff=1178807"/>
		<updated>2013-06-03T17:38:21Z</updated>

		<summary type="html">&lt;p&gt;Gistya Eusebio: Added another issue with the function to caveats.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{LSL_Function&lt;br /&gt;
|func_id=343|func_sleep=0.0|func_energy=10.0&lt;br /&gt;
|func=llSHA1String|return_type=string|p1_type=string|p1_name=src&lt;br /&gt;
|func_footnote&lt;br /&gt;
|func_desc&lt;br /&gt;
|return_text=of 40 hex characters that is the {{Wikipedia|SHA-1|SHA-1}} security hash of &#039;&#039;&#039;src&#039;&#039;&#039;.&lt;br /&gt;
|spec=LSL strings are stored in the UTF-8 format.&lt;br /&gt;
|caveats=There&#039;s no way to input a zero-byte value into this function, nor any byte value from 128-255, therefore it&#039;s currently broken for many purposes (like HMAC-SHA1). The reason is because LSL strings cannot have a unicode null character (U+0000) in them, and LSL has no escape code for the null character (many programming languages use \0 but LSL does not have this feature). llEscapeURL(&amp;quot;%00&amp;quot;) yields an empty string. As well, inside this function, each character with a Unicode integer value  byte values over U+0127 / 007F are dealt with in UTF-8 fashion: in the hex values, 0xC2 is appended to the byte value (hence 0x0080-0x00FF become 0xC280-0xC2FF inside the llSHA1String() routine). A JIRA has been filed for this.&lt;br /&gt;
|constants&lt;br /&gt;
|examples=&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
llSay(0, llSHA1String(&amp;quot;Hello, Avatar!&amp;quot;)); // returns 2E73318E547AF1B28CC0C96F95DDC9B1EE906B8D&lt;br /&gt;
&amp;lt;/lsl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Linux Example====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ echo -n &#039;Hello, Avatar!&#039; | openssl sha1&lt;br /&gt;
2E73318E547AF1B28CC0C96F95DDC9B1EE906B8D&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|helpers&lt;br /&gt;
|also_functions=&lt;br /&gt;
{{LSL DefineRow||[[llMD5String]]}}&lt;br /&gt;
|also_tests&lt;br /&gt;
|also_events&lt;br /&gt;
|also_articles=&lt;br /&gt;
{{LSL DefineRow||[[SHA-1]]}}&lt;br /&gt;
|notes&lt;br /&gt;
|deepnotes=&lt;br /&gt;
Prior to this, the only way to get the SHA-1 hash was to use the LSL SHA-1 port: [[SHA-1]]&lt;br /&gt;
|history=&lt;br /&gt;
*{{SVN|1291|rev=98903|trunk=*|anchor=file13|ver=1.21.5.97417|ser=1.24.9.98650}} Initial introduction.&lt;br /&gt;
*{{SVN|1298|rev=99021|branch=OpenAL|ver=1.21.5.97417|ser=1.24.9.98650|path=branches/openal/indra/lscript/lscript_library/lscript_library.cpp}} Integration into OpenAL branch.&lt;br /&gt;
|cat1=Hash&lt;br /&gt;
|cat2=Encoding&lt;br /&gt;
|cat3&lt;br /&gt;
|cat4&lt;br /&gt;
}}{{LSLC{{#var:lang}}|Encryption|llSHA1String}}&lt;/div&gt;</summary>
		<author><name>Gistya Eusebio</name></author>
	</entry>
	<entry>
		<id>https://wiki.secondlife.com/w/index.php?title=Talk:Json_usage_in_LSL&amp;diff=1178724</id>
		<title>Talk:Json usage in LSL</title>
		<link rel="alternate" type="text/html" href="https://wiki.secondlife.com/w/index.php?title=Talk:Json_usage_in_LSL&amp;diff=1178724"/>
		<updated>2013-05-30T16:41:02Z</updated>

		<summary type="html">&lt;p&gt;Gistya Eusebio: Asking how escaped characters in JSON strings will be rendered&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I am concerned because the JSON format specifies at json.org that you can use escape codes like \u0000 to represent Unicode byte values in strings. But LSL has the ugly habit of censoring and altering strings so that a character with byte value of 0x0000 is removed from the string, and some functions like llSHA1String are essentially broken since they also convert UTF-16 integers between \u0128–\u0255 into UTF-8 byte values starting with %c2 (which therefore have a different integer value due to the addition of the extraneous byte). Is LSL also going to mangle JSON strings&#039; byte values when it renders them into LSL strings? Won&#039;t this corrupt attempts at efficiently verifying the signatures of any incoming messages, and thwart attempts to generate proper signatures for some outgoing JSON-formatted requests? Or do the Lindens have plans to finally give us a proper suite of escape codes in LSL (or some other solution)?&lt;br /&gt;
--[[User:Gistya Eusebio|Gistya Eusebio]] 09:41, 30 May 2013 (PDT)&lt;/div&gt;</summary>
		<author><name>Gistya Eusebio</name></author>
	</entry>
	<entry>
		<id>https://wiki.secondlife.com/w/index.php?title=User:Gistya_Eusebio&amp;diff=1178429</id>
		<title>User:Gistya Eusebio</title>
		<link rel="alternate" type="text/html" href="https://wiki.secondlife.com/w/index.php?title=User:Gistya_Eusebio&amp;diff=1178429"/>
		<updated>2013-05-20T02:28:33Z</updated>

		<summary type="html">&lt;p&gt;Gistya Eusebio: Created page with &amp;quot;I&amp;#039;ve been using second life since 2006. I own the sim, Korriban. I&amp;#039;m a scripter.&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I&#039;ve been using second life since 2006. I own the sim, Korriban. I&#039;m a scripter.&lt;/div&gt;</summary>
		<author><name>Gistya Eusebio</name></author>
	</entry>
	<entry>
		<id>https://wiki.secondlife.com/w/index.php?title=LlSHA1String&amp;diff=1178428</id>
		<title>LlSHA1String</title>
		<link rel="alternate" type="text/html" href="https://wiki.secondlife.com/w/index.php?title=LlSHA1String&amp;diff=1178428"/>
		<updated>2013-05-20T02:27:44Z</updated>

		<summary type="html">&lt;p&gt;Gistya Eusebio: added caveat&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{LSL_Function&lt;br /&gt;
|func_id=343|func_sleep=0.0|func_energy=10.0&lt;br /&gt;
|func=llSHA1String|return_type=string|p1_type=string|p1_name=src&lt;br /&gt;
|func_footnote&lt;br /&gt;
|func_desc&lt;br /&gt;
|return_text=of 40 hex characters that is the {{Wikipedia|SHA-1|SHA-1}} security hash of &#039;&#039;&#039;src&#039;&#039;&#039;.&lt;br /&gt;
|spec=LSL strings are stored in the UTF-8 format.&lt;br /&gt;
|caveats=There&#039;s no way to input a zero-byte value into this function, therefore it&#039;s currently broken for many purposes (like HMAC-SHA1). The reason is because LSL strings cannot have a unicode null character (U+0000) in them, and LSL has no escape code for the null character (many programming languages use \0 but LSL does not have this feature). llEscapeURL(&amp;quot;%00&amp;quot;) yields an empty string. A JIRA has been filed for this.&lt;br /&gt;
|constants&lt;br /&gt;
|examples=&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
llSay(0, llSHA1String(&amp;quot;Hello, Avatar!&amp;quot;)); // returns 2E73318E547AF1B28CC0C96F95DDC9B1EE906B8D&lt;br /&gt;
&amp;lt;/lsl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Linux Example====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ echo -n &#039;Hello, Avatar!&#039; | openssl sha1&lt;br /&gt;
2E73318E547AF1B28CC0C96F95DDC9B1EE906B8D&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|helpers&lt;br /&gt;
|also_functions=&lt;br /&gt;
{{LSL DefineRow||[[llMD5String]]}}&lt;br /&gt;
|also_tests&lt;br /&gt;
|also_events&lt;br /&gt;
|also_articles=&lt;br /&gt;
{{LSL DefineRow||[[SHA-1]]}}&lt;br /&gt;
|notes&lt;br /&gt;
|deepnotes=&lt;br /&gt;
Prior to this, the only way to get the SHA-1 hash was to use the LSL SHA-1 port: [[SHA-1]]&lt;br /&gt;
|history=&lt;br /&gt;
*{{SVN|1291|rev=98903|trunk=*|anchor=file13|ver=1.21.5.97417|ser=1.24.9.98650}} Initial introduction.&lt;br /&gt;
*{{SVN|1298|rev=99021|branch=OpenAL|ver=1.21.5.97417|ser=1.24.9.98650|path=branches/openal/indra/lscript/lscript_library/lscript_library.cpp}} Integration into OpenAL branch.&lt;br /&gt;
|cat1=Hash&lt;br /&gt;
|cat2=Encoding&lt;br /&gt;
|cat3&lt;br /&gt;
|cat4&lt;br /&gt;
}}{{LSLC{{#var:lang}}|Encryption|llSHA1String}}&lt;/div&gt;</summary>
		<author><name>Gistya Eusebio</name></author>
	</entry>
	<entry>
		<id>https://wiki.secondlife.com/w/index.php?title=Category:LSL_String&amp;diff=1178427</id>
		<title>Category:LSL String</title>
		<link rel="alternate" type="text/html" href="https://wiki.secondlife.com/w/index.php?title=Category:LSL_String&amp;diff=1178427"/>
		<updated>2013-05-20T01:48:19Z</updated>

		<summary type="html">&lt;p&gt;Gistya Eusebio: it needs to be explained that strings cannot contain &amp;quot;NUL&amp;quot; characters.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{LSL Header|ml=*}}{{LSLC|}}{{LSLC|Types}}&lt;br /&gt;
{{RightToc}}&lt;br /&gt;
&lt;br /&gt;
See also [[:Category:LSL_Text|Text]].&lt;br /&gt;
&lt;br /&gt;
A string is text data.&lt;br /&gt;
&lt;br /&gt;
String values are enclosed in double quotes when defined in LSL text.&lt;br /&gt;
&lt;br /&gt;
Any character may be used in a string, except for the &amp;quot;NUL&amp;quot; character, though some will need to be escaped (see the [[#Escape Codes|Escape Codes section]] on this page for more info.) The &amp;quot;NUL&amp;quot; character is Unicode value U+0000 and cannot exist in an LSL string. Therefore for example llUnescapeURL(&amp;quot;%00&amp;quot;) results in an empty string &amp;quot;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The length of a string is only limited by available [[LlGetFreeMemory|script memory]]. (see the [[#String_Length_Restraints|String Length Restraints]] section on this page for some operational restraints.) But note that in Mono, strings use UTF-16 and occupy two memory bytes per character.&lt;br /&gt;
&lt;br /&gt;
Strings can be concatenated (joined together) using the &#039;&#039;&#039;+&#039;&#039;&#039; operator. Note that concatenation cannot be done when defining a string as a global variable, as + is treated as an executable instruction, it&#039;s not handled by the compiler. Concatenation can only be done within executable code, i.e. inside a user defined function or in an event.&lt;br /&gt;
&lt;br /&gt;
Some string operations can be done via built-in functions, such as those that can make text all upper and lower case. Other operations, such as replace, left, right, wrap, etc, must be done via functions invented by other LSL users (examples of which are at the bottom of this page.)&lt;br /&gt;
&lt;br /&gt;
You have no control over the font face, size, weight or colour that string output is displayed in on user screens or on menus. The look of text that displays on screens, such as chat from a text, is controlled by users (though not many change the defaults.) You can only control whether the text is lower or upper case.&lt;br /&gt;
&lt;br /&gt;
(The only time you have control over the colour of displayed text is when it is [[LlSetText|Floating Text]].)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|&lt;br /&gt;
String examples:&lt;br /&gt;
&amp;lt;lsl&amp;gt;&amp;quot;Hello Avatar!&amp;quot;&lt;br /&gt;
&amp;quot;Yes&amp;quot;&lt;br /&gt;
&amp;quot;No&amp;quot;&lt;br /&gt;
&amp;quot;It&#039;s 10 o&#039;clock.&amp;quot;&lt;br /&gt;
&amp;quot;I am 21 years old!&amp;quot;&lt;br /&gt;
&amp;quot;Help &amp;quot; + &amp;quot;me&amp;quot;&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
//The following two strings have the same value (i.e. they will both produce text with line breaks in it.)&lt;br /&gt;
&lt;br /&gt;
&amp;quot;I scream,\nyou scream,\nwe all scream,\nfor ice-cream!&amp;quot;&lt;br /&gt;
&amp;quot;I scream,&lt;br /&gt;
you scream,&lt;br /&gt;
we all scream,&lt;br /&gt;
for ice-cream!&amp;quot;&lt;br /&gt;
&amp;lt;/lsl&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{#vardefine:p_name_desc|variable name&lt;br /&gt;
}}{{#vardefine:p_value_desc|string expression or constant&lt;br /&gt;
}}{{#vardefine:p_value_t_desc|expression or constant&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;div id=&amp;quot;box&amp;quot;&amp;gt;&lt;br /&gt;
== Variable: string {{LSL Param|name}}; ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;padding: 0.5em;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;lsl&amp;gt;string name;&amp;lt;/lsl&amp;gt;&lt;br /&gt;
Declares a variable of type string named &#039;&#039;&#039;name&#039;&#039;&#039;, with the value {{HoverText|&amp;quot;&amp;quot;|empty string}}&lt;br /&gt;
{|&lt;br /&gt;
{{LSL DefineRow|variable|name|{{#var:p_name_desc}}}}&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;box&amp;quot;&amp;gt;&lt;br /&gt;
== Variable: string {{LSL Param|name}} {{=}} {{LSL Param|value}}; ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;padding: 0.5em;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;lsl&amp;gt;string name = value;&amp;lt;/lsl&amp;gt;&lt;br /&gt;
Declares a variable of type string named &#039;&#039;&#039;name&#039;&#039;&#039;, with the value &#039;&#039;&#039;value&#039;&#039;&#039;.&lt;br /&gt;
{|&lt;br /&gt;
{{LSL DefineRow|variable|name|{{#var:p_name_desc}}}}&lt;br /&gt;
{{LSL DefineRow|expression|value|{{#var:p_value_desc}}}}&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;box&amp;quot;&amp;gt;&lt;br /&gt;
== [[Typecast]]: (string){{LSL Param|value_t|value}} ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;padding: 0.5em;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;lsl&amp;gt;(string)value&amp;lt;/lsl&amp;gt;&lt;br /&gt;
Converts &#039;&#039;&#039;value&#039;&#039;&#039; to a value of type string.&lt;br /&gt;
{|&lt;br /&gt;
{{LSL DefineRow|expression|value|{{#var:p_value_t_desc}}}}&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;box&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== [[LSL Operators|Operators]] == &lt;br /&gt;
&amp;lt;div style=&amp;quot;padding: 0.5em;&amp;quot;&amp;gt;&lt;br /&gt;
See [[LSL Operators|Operators]] for more information.&lt;br /&gt;
&amp;lt;div id=&amp;quot;box&amp;quot; style=&amp;quot;padding-left: 0.5em;padding-right: 0.5em;padding-bottom: 0.5em;&amp;quot;&amp;gt;&lt;br /&gt;
=== Combine: {{LSL Param|value|value1}} + {{LSL Param|value|value2}} ===&lt;br /&gt;
&amp;lt;lsl&amp;gt;(value1 + value2)&amp;lt;/lsl&amp;gt;&lt;br /&gt;
Combines two strings into a single string without modifying the inputs. Appends &#039;&#039;&#039;value2&#039;&#039;&#039; to &#039;&#039;&#039;value1&#039;&#039;&#039; and returns the resulting string.&lt;br /&gt;
{|&lt;br /&gt;
{{LSL DefineRow|expression|value1|{{#var:p_value_desc}}}}&lt;br /&gt;
{{LSL DefineRow|expression|value2|{{#var:p_value_desc}}}}&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;box&amp;quot; style=&amp;quot;padding-left: 0.5em;padding-right: 0.5em;padding-bottom: 0.5em;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Comparison: {{LSL Param|value|value1}} &amp;lt;nowiki&amp;gt;==&amp;lt;/nowiki&amp;gt; {{LSL Param|value|value2}} ===&lt;br /&gt;
&amp;lt;lsl&amp;gt;(value1 == value2)&amp;lt;/lsl&amp;gt;&lt;br /&gt;
Compares two strings, returns {{HoverText|one|1}} if same length and same characters, else returns zero.&lt;br /&gt;
This operator works exactly like &amp;lt;code&amp;gt;!strcmp(&#039;&#039;&#039;value1&#039;&#039;&#039;, &#039;&#039;&#039;value2&#039;&#039;&#039;)&amp;lt;/code&amp;gt; in C, thus technically differs from the counterintuitive behavior of the == operator in C and in Java.&lt;br /&gt;
{|&lt;br /&gt;
{{LSL DefineRow|expression|value1|{{#var:p_value_desc}}}}&lt;br /&gt;
{{LSL DefineRow|expression|value2|{{#var:p_value_desc}}}}&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;box&amp;quot; style=&amp;quot;padding-left: 0.5em;padding-right: 0.5em;padding-bottom: 0.5em;&amp;quot;&amp;gt;&lt;br /&gt;
=== Comparison: {{LSL Param|value|value1}} != {{LSL Param|value|value2}} ===&lt;br /&gt;
&amp;lt;lsl&amp;gt;(value1 != value2)&amp;lt;/lsl&amp;gt;&lt;br /&gt;
Compares two strings, returns {{HoverText|zero|0}} if same length and same characters, otherwise non-zero.&lt;br /&gt;
This operator works exactly like &amp;lt;code&amp;gt;strcmp(&#039;&#039;&#039;value1&#039;&#039;&#039;, &#039;&#039;&#039;value2&#039;&#039;&#039;)&amp;lt;/code&amp;gt; in C, thus technically differs from the counterintuitive behavior of the != operator in C and in Java.&lt;br /&gt;
{|&lt;br /&gt;
{{LSL DefineRow|expression|value1|{{#var:p_value_desc}}}}&lt;br /&gt;
{{LSL DefineRow|expression|value2|{{#var:p_value_desc}}}}&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;box&amp;quot;&amp;gt;&lt;br /&gt;
== Escape Codes==&lt;br /&gt;
&amp;lt;div style=&amp;quot;padding: 0.5em;&amp;quot;&amp;gt;&lt;br /&gt;
{|{{Prettytable|style=float:left;}}&lt;br /&gt;
|+&lt;br /&gt;
|-{{Hl2}}&lt;br /&gt;
!Substring&lt;br /&gt;
!Replaced with&lt;br /&gt;
|-&lt;br /&gt;
|| \t || four spaces&lt;br /&gt;
|-&lt;br /&gt;
|| \n || new line&lt;br /&gt;
|-&lt;br /&gt;
|| \&amp;quot; || double quote&lt;br /&gt;
|-&lt;br /&gt;
|| \\ || backslash&lt;br /&gt;
|}&lt;br /&gt;
Escape codes are translated when the script is compiled; not while it&#039;s running. The compiler will ignore any other combination of \ with a character by removing the \. So &amp;quot;\a&amp;quot; means &amp;quot;a&amp;quot;.&lt;br /&gt;
The result is that only strings that are inside your script when it is compiled will get, say, \n turned into a &amp;quot;new line&amp;quot; character.  Text you read in from a notecard, chat, http, object name or description, etc, will not be checked for escape codes -- that same \n typed in a notecard doesn&#039;t automatically turn into a &amp;quot;new line&amp;quot; character.  You&#039;ll have to do that yourself, if you really really need it for some reason. &lt;br /&gt;
&lt;br /&gt;
Those who are coming to LSL from such languages as C and Java may find these LSL string escape rules confusing at first. In LSL, &amp;quot;\n&amp;quot; means [[llUnescapeURL]](&amp;quot;%0A&amp;quot;), as it does in C and Java, but &amp;quot;\t&amp;quot; means [[llUnescapeURL]](&amp;quot;%20%20%20%20&amp;quot;) rather than [[llUnescapeURL]](&amp;quot;%09&amp;quot;). Additionally there is no &amp;quot;\r&amp;quot; escape code and &amp;quot;\r&amp;quot; will translate to &amp;quot;r&amp;quot; rather than [[llUnescapeURL]](&amp;quot;%0D&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
For runtime translation of escaped characters try the user function [[Unescape]].&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;box&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Characters with Accents==&lt;br /&gt;
&amp;lt;div style=&amp;quot;padding: 0.5em;&amp;quot;&amp;gt;&lt;br /&gt;
It used to be that your script would not compile if you included in it a string containing a character with an accent, such as &amp;quot;écoutez&amp;quot;, or punctuation not used in English, such as &amp;quot;¿Entiende?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Sometime in late spring / early summer 2008, scripts began compiling with accents in text strings.&lt;br /&gt;
&lt;br /&gt;
That is to say:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;lsl&amp;gt;string hello = &amp;quot;Avatar écoutez&amp;quot;;&amp;lt;/lsl&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;box&amp;quot;&amp;gt;&lt;br /&gt;
==String Length Restraints==&lt;br /&gt;
&amp;lt;div style=&amp;quot;padding: 0.5em;&amp;quot;&amp;gt;&lt;br /&gt;
As noted at the start of this page, the length of a single string is only limited by available [[script memory]]. However, there are some operational limitations. Many {{LSLGC|Communications}} functions and some other functions also impose limits on input strings. Those limits may result in error messages at runtime or &amp;quot;silent&amp;quot; truncation (i.e. you get no error notice, nor any indication that it has been done.).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Examples&#039;&#039;&#039;&lt;br /&gt;
* [[llSay]] -  When using llSay, any text string being said will be truncated to 1024 CHARACTERS, both under LSO and Mono. (That&#039;s 2048 bytes of memory space in Mono (UTF-16) ).&lt;br /&gt;
* [[llGetNotecardLine]] - When reading in lines from notecards, lines longer than 255 characters will be truncated silently.&lt;br /&gt;
* [[llDialog]] - If the message or button texts are too long a non-fatal error is produced when the function is called.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes&#039;&#039;&#039;&amp;lt;br/&amp;gt;&lt;br /&gt;
Limits of this type are always documented, an absence of limits in the documentation means there are no known limits (that are outside the norm for the language).&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;box&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Trimming a String==&lt;br /&gt;
&amp;lt;div style=&amp;quot;padding: 0.5em;&amp;quot;&amp;gt;&lt;br /&gt;
Trimming a string used to require user-created functions, such as those created for the purpose in Strife Onizuka&#039;s library.&lt;br /&gt;
&lt;br /&gt;
Now, however, there is a native LSL function, [[llStringTrim]], which can be used to remove leading and/or trailing spaces. Note though that it does not remove excess spaces that a user may have entered in the middle of a sentence or string, nor is there any other native LSL function which does.&lt;br /&gt;
&lt;br /&gt;
The following code &#039;&#039;will&#039;&#039; remove both all double spaces inside a string, as well as any leading and trailing spaces; it will how ever require a substantial amount of memory overhead.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;lsl&amp;gt;string myTrimmedText = llDumpList2String(llParseString2List(src, [&amp;quot; &amp;quot;], []), &amp;quot; &amp;quot;);&amp;lt;/lsl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When accepting user text input from chat, a notecard, or a prim name or description, or any other &amp;quot;free-wheeling&amp;quot; source, it&#039;s a good idea to always [[llStringTrim]] first before beginning to work with it.&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;box&amp;quot;&amp;gt;&lt;br /&gt;
== Examples ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;padding: 0.5em;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;lsl&amp;gt;integer int = 48934;&lt;br /&gt;
string str = (string)int;&lt;br /&gt;
string str_2;&lt;br /&gt;
str_2 = str;&amp;lt;/lsl&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;box&amp;quot;&amp;gt;&lt;br /&gt;
== Useful Functions ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;padding: 0.5em;&amp;quot;&amp;gt;&lt;br /&gt;
=== User-created utility functions ===&lt;br /&gt;
These functions have been created and contributed by LSL users to perform operations not covered by built-in LSL functions.&lt;br /&gt;
&lt;br /&gt;
{|{{Prettytable}}&lt;br /&gt;
|+&lt;br /&gt;
|-{{Hl2}}&lt;br /&gt;
!function&lt;br /&gt;
!purpose&lt;br /&gt;
|-&lt;br /&gt;
|| [[Chr]] || Returns the Unicode character with the given code. See also [[Ord]].&lt;br /&gt;
|-&lt;br /&gt;
|| [[Float2String]] || Allows string output of a float in a tidy text format, with optional rounding.&lt;br /&gt;
|-&lt;br /&gt;
|| [[Left]] || Returns text left of a specified separator.&lt;br /&gt;
|-&lt;br /&gt;
|| [[Like]] || See if one word matches part of another.&lt;br /&gt;
|-&lt;br /&gt;
|| [[Ord]] || Returns the ordinal (Unicode code) of a character. See also [[Chr]].&lt;br /&gt;
|-&lt;br /&gt;
|| [[RandomString]] || Creates a random string.&lt;br /&gt;
|-&lt;br /&gt;
|| [[RemoveHTMLTags]] || Removes HTML tags from a string ( and newline characters )&lt;br /&gt;
|-&lt;br /&gt;
|| [[Right]] || Returns text right of a specified separator.&lt;br /&gt;
|-&lt;br /&gt;
|| [[Library_Combined_Library#str_replace|str_replace]] || replace all instances of a string with another string in a target string.&lt;br /&gt;
|-&lt;br /&gt;
|| [[Stristr]] || Returns a string from the first occurrence of needle to the end of haystack.&lt;br /&gt;
|-&lt;br /&gt;
|| [[SplitLine]] || Insert &#039;new line&#039; escape codes at certain positions of a string.&lt;br /&gt;
|-&lt;br /&gt;
|| [[WrapText]] || Break text into line lengths of your specification.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Text-Related Items from the Script Library ===&lt;br /&gt;
{| {{Prettytable}}&lt;br /&gt;
|-&lt;br /&gt;
|{{Hl2}}| &#039;&#039;&#039;Name&#039;&#039;&#039;&lt;br /&gt;
|{{Hl2}}| &#039;&#039;&#039;Creator&#039;&#039;&#039;&lt;br /&gt;
|{{Hl2}}| &#039;&#039;&#039;Description&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
||[[ParseString2List]]&lt;br /&gt;
||[[User:Strife Onizuka|Strife Onizuka]]&lt;br /&gt;
||Same as [[llParseString2List]] and [[llParseStringKeepNulls]], but not limited to 8 spacers or separators. Thus substitute a call to the [[llParseString2List]] and [[llParseStringKeepNulls]] functions by a call to [[Parse_String_To_List|ParseString2List]] whenever you have more than 8 separators or more than 8 spacers.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
||[[String Compare]]&lt;br /&gt;
||[[User:Xaviar Czervik|Xaviar Czervik]]&lt;br /&gt;
||Compares two strings and reliably returns either 1, -1, or 0 if they are the same.&lt;br /&gt;
|-&lt;br /&gt;
||[[XyText 1.5|XyText]]&lt;br /&gt;
||[[User:Xylor Baysklef|Xylor Baysklef]]&lt;br /&gt;
|| Display text (up to 10 characters) on a prim. Use as many prims as desired.&lt;br /&gt;
|-&lt;br /&gt;
||[[XyyyyzText|XyyyyzText]]&lt;br /&gt;
||[[User:Criz Collins|Criz Collins]]&lt;br /&gt;
|| Display text (up to 10 characters) on a prim. Displays different text for each line instead of one single text, that will be broken into the next lines. Watch here for what that means: http://screencast.com/t/1wMLujLcEO&lt;br /&gt;
|-&lt;br /&gt;
||[[XyzzyText|XyzzyText]]&lt;br /&gt;
||[[User:Thraxis Epsilon|Thraxis Epsilon]] and [[User:Gigs Taggart|Gigs Taggart]]&lt;br /&gt;
|| Display text (up to 10 characters) on a prim. Way more efficient than XyText.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Gistya Eusebio</name></author>
	</entry>
	<entry>
		<id>https://wiki.secondlife.com/w/index.php?title=File_talk:Sculpted-preview-03.png&amp;diff=21497</id>
		<title>File talk:Sculpted-preview-03.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.secondlife.com/w/index.php?title=File_talk:Sculpted-preview-03.png&amp;diff=21497"/>
		<updated>2007-05-24T10:42:08Z</updated>

		<summary type="html">&lt;p&gt;Gistya Eusebio: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Why does the sculptedpreview program have an XBOX 360 controller for its icon?&lt;br /&gt;
&lt;br /&gt;
Is LL going to put out an SL client for the 360? OMG that would be so sweet!!&lt;/div&gt;</summary>
		<author><name>Gistya Eusebio</name></author>
	</entry>
</feed>