json.set: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
No edit summary
Line 2: Line 2:
|name=json.set
|name=json.set
|version=1.3b49
|version=1.3b49
|description
|description=
Sets the value in at the specified index in a [[Macros:json array|json array]] or for the specified key in a [[Macros:json object|json object]]. You can use an empty string ("") to represent a new json object.
Sets the value in at the specified index in a [[Macros:json array|json array]] or for the specified key in a [[Macros:json object|json object]]. You can use an empty string ("") to represent a new json object.


|usage=
|usage=
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[h: jarr = json.set(jarr, index, value)]
[h: jarr = json.set(jobj, key, value)]
[h: jarr = json.set(jobj, key, value)]
[h: jarr = json.set(jobj, key, value, ..., ...)]
[h: jarr = json.set(jobj, key, value, ..., ...)]
[h: jarr = json.set(jarr, index, value)]
</source>
</source>



Revision as of 19:10, 19 April 2009

json.set() Function

Introduced in version 1.3b49
Sets the value in at the specified index in a json array or for the specified key in a json object. You can use an empty string ("") to represent a new json object.

Usage

[h: jarr = json.set(jobj, key, value)]
[h: jarr = json.set(jobj, key, value, ..., ...)]
[h: jarr = json.set(jarr, index, value)]

Example

  [json.set("{}", "a", 5)]
  [json.set("", "a", 5, "b", 8)]
  [json.set(json.fromList("1,3"), 0, 8)]

Returns

 {"a":5}
 {"a":5, "b":8}
[8, 3]