Difference between revisions of "LlJsonSetValue"

From Second Life Wiki
Jump to navigation Jump to search
m
(Expanded on function description.)
Line 3: Line 3:
|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
|func_footnote
|func_footnote
|func_desc=Returns a new [http://json.org JSON] string which is ''string'' with the value indicated by specifiers set to ''value''.<br/><br/>A special specifier, [[JSON_APPEND]] is accepted which facilitates appending the value to the end of the array at the specified level.<br.>Care should be taken, as if the value at that level is not an array, the existing data will be overwritten and replaced with the array meant for appending.
|func_desc=Returns, if successful, a new [http://json.org 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''.
 
|return_text=
|return_text=
|spec=See [[Json_usage_in_LSL]]
|spec=See [[Json_usage_in_LSL]]

Revision as of 16:05, 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

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 );