json.merge

From RPTools Wiki
Revision as of 13:30, 29 March 2009 by Craig (talk | contribs) (New page: {{MacroFunction |name=json.merge |version=1.3b53 |description= Merges multiple JSON Arrays or JSON Objects. For JSON Arrays the value returned is that of all the JSON Array...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

json.merge() Function

Introduced in version 1.3b53
Merges multiple JSON Arrays or JSON Objects. For JSON Arrays the value returned is that of all the JSON Arrays concatenated together. For JSON Objects the value returned is a JSON Object with all of the keys from all of the JSON Objects set, if eny key is specified in more than one JSON Object then the value for the last specified JSON Object is used.

Usage

[h: jarr = json.merge(jarr, jarr, ...)]
[h: jarr = json.merge(jobj, jobj, ...)]

Parameters

Examples

[r: json.merge("[1,2]", "[3,4]", "[1,2]")]

Returns [1,2,3,4,1,2]

[r: json.merge("{a:1, b:2}", "{c:10, d:7}")]

Returns {"a":1,"b":2,"c":10,"d":7}

[r: json.merge("{a:1, b:2}", "{c:10, d:7}", "{a:11, z:7}")]

Returns

{"a":11,"b":2,"c":10,"d":7,"z":7}

Version Changes

  • 1.3b54 - fixed bug which allows json.merge() to work correctly with JSON Objects.