json.union: Difference between revisions
Jump to navigation
Jump to search
Verisimilar (talk | contribs) (Initial write-up.) |
No edit summary |
||
(7 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
{{MacroFunction | {{MacroFunction | ||
|name=json.union | |name=json.union | ||
|version=1.3b53 | |version=1.3b53 | ||
|description= | |description= | ||
Returns an [[JSON Array]] with the union of all of the [[JSON Object]] keys, or [[JSON Array]] values. | Returns an [[JSON Array]] with the union of all of the [[JSON Object]] keys, or [[JSON Array]] values. If a value or a key occurs in multiple different objects or arrays, it will only be placed once in the output object or array. | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
json.union(array, array, ...) | json.union(array, array, ...) | ||
</ | </syntaxhighlight> | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
json.union(object, object, ...) | json.union(object, object, ...) | ||
</ | </syntaxhighlight> | ||
'''Parameters''' | '''Parameters''' | ||
{{param|array|The [[JSON Array]]s to union.}} | {{param|array|The [[JSON Array]]s to union.}} | ||
{{param|object|The [[JSON Object]]s to union.}} | {{param|object|The [[JSON Object]]s to union.}} | ||
|examples= | |||
<syntaxhighlight lang="mtmacro" line> | |||
[h: array1 = json.append("",1,2,3,4)] | |||
[h: array2 = json.append("",3,4,5,6)] | |||
[r: json.union(array1,array2)] | |||
</syntaxhighlight> | |||
Returns | |||
"[1,2,3,4,5,6]" | |||
|also= | |also= | ||
{{func|json.merge}} | {{func|json.merge}}, {{func|json.intersection}} | ||
}} | }} | ||
[[Category:JSON Function]] |
Latest revision as of 23:59, 15 March 2023
json.union() Function
• Introduced in version 1.3b53
Returns an JSON Array with the union of all of the JSON Object keys, or JSON Array values. If a value or a key occurs in multiple different objects or arrays, it will only be placed once in the output object or array.
Usage
json.union(array, array, ...)
json.union(object, object, ...)
Parameters
array
- The JSON Arrays to union.object
- The JSON Objects to union.
Examples
[h: array1 = json.append("",1,2,3,4)]
[h: array2 = json.append("",3,4,5,6)]
[r: json.union(array1,array2)]
Returns
"[1,2,3,4,5,6]"