Difference between revisions of "LlJsonSetValue"

From Second Life Wiki
Jump to navigation Jump to search
(Added caveat.)
m
Line 1: Line 1:
{{LSL Function
{{LSL Function
|inject-2={{Issues/BUG-3692}}
|func_id=|func_sleep=0.0|func_energy=10.0
|func_id=|func_sleep=0.0|func_energy=10.0
|func=llJsonSetValue|return_type=string|p1_type=string|p1_name=json|p2_type=list|p2_name=specifiers|p3_type=string|p3_name=value
|func=llJsonSetValue|return_type=string|p1_type=string|p1_name=json|p2_type=list|p2_name=specifiers|p3_type=string|p3_name=value
Line 21: Line 22:
|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]].''
|caveats=
|helpers
|helpers
|also_functions={{LSL DefineRow||[[llList2Json]]|}}
|also_functions={{LSL DefineRow||[[llList2Json]]|}}

Revision as of 01:41, 31 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

Examples

See Also

Functions

•  llList2Json
•  llJson2List
•  llJsonGetValue
•  llJsonValueType

Articles

•  Typecast

Deep Notes

History

Date of Release 20/05/2013

All Issues

~ Search JIRA for related Issues
   JSON_NULL may be deceptively returned instead of JSON_INVALID when noncompliant Json text is encountered by either llJsonValueType or llJsonGetValue. Fixed with release 13.09.21.281328.

Signature

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