json.set: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Applied Template:MacroFunction)
Line 1: Line 1:
==Function json.set==
{{MacroFunction
 
|name=json.set
 
|version=1.3b49
 
|description
'''Introduced in MapTool 1.3b49'''
 
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(jarr, index, value)]
Line 14: Line 12:
</source>
</source>


===Examples===
|example=
<source lang="mtmacro" line>
<source lang="mtmacro" line>
   [json.set("{}", "a", 5)]
   [json.set("{}", "a", 5)]
Line 25: Line 23:
   {"a":5, "b":8}
   {"a":5, "b":8}
   [8, 3]
   [8, 3]
}}
[[Category:JSON Function]]

Revision as of 02:14, 9 March 2009

json.set() Function

Introduced in version 1.3b49

Usage

[h: jarr = json.set(jarr, index, value)]
[h: jarr = json.set(jobj, key, value)]
[h: jarr = json.set(jobj, key, 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]