Difference between revisions of "LlJsonSetValue"

From Second Life Wiki
Jump to navigation Jump to search
(Expanded on function description.)
(Added caveat.)
Line 21: Line 21:
|constants
|constants
|examples=
|examples=
|caveats=*[https://jira.secondlife.com/browse/BUG-3692 BUG-3692] ''LlJsonSetValue may form [http://tools.ietf.org/html/rfc4627 noncompliant Json text] from "out of range index values" which leads to deceptive return strings by either [[llJsonValueType]] or [[llJsonGetValue]].''
|helpers
|helpers
|also_functions={{LSL DefineRow||[[llList2Json]]|}}
|also_functions={{LSL DefineRow||[[llList2Json]]|}}

Revision as of 16:41, 30 August 2013

Summary

Function: string llJsonSetValue( string json, list specifiers, string value );

Returns, if successful, a new JSON text string which is json with the value indicated by the specifiers list set to value.

If unsuccessful (usually because of specifying an out of range array index) it should, and usually will, return JSON_INVALID. However this is currently, 8/20/2013, broken at depths lower than the topmost level, where it will silently invalidate the return string, so be careful! The return string should always be checked for JSON_INVALID before overwriting the original Json text.

An "out of range array index" is defined to be any Integer specifier greater than the length of an existing array at that level within the Json text or greater than 0 (zero) at a level an array doesn't exist.

A special specifier, JSON_APPEND, is accepted which appends the value to the end of the array at the specified level. Care should be taken- if that level is not an array, the existing Value there will be overwritten and replaced with an array containing value at it's first (0) index.

Contrary to LSL_List, negative indexing of Json arrays is not supported.

If an existing "Key" is specified at that level, its Value will be overwritten by value, otherwise a new "Key":Value pair will be formed within the Json object.

If value is JSON_TRUE, JSON_FALSE or JSON_NULL, the Value set will be the bare words 'true', 'false' or 'null', respectively, at the specified location within json.
Returns a string

• string json
• list specifiers
• string value

Specification

Caveats

All Issues ~ Search JIRA for related Bugs

Examples

See Also

Functions

•  llList2Json
•  llJson2List
•  llJsonGetValue
•  llJsonValueType

Articles

•  Typecast

Deep Notes

History

Date of Release 20/05/2013

Search JIRA for related Issues

Signature

function string llJsonSetValue( string json, list specifiers, string value );