Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
JSON.Merge
Merges multiple JSON objects or arrays.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
JSON | 14.2 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
Parameter | Description | Example |
---|---|---|
json1 | A JSON text or reference. | {"key": "value"} |
json2... | A JSON text or reference. | {"key2": "value2"} |
Result
Returns JSON or error.
Description
Merges multiple JSON objects or arrays.You can pass more than 2 parameters if you need to merge multiple objects or arrays.
For arrays, we check if the value is already there and if not, we add it.
For objects, we check the values for each key. If it doesn't exist, we copy it over. If it exists, we check arrays and objects again, but other values just get replaced.
This function takes variable number of parameters. Pass as much parameters as needed separated by the semicolon in FileMaker.
Please repeat json2 parameter as often as you need.
Examples
Merge two arrays:
MBS("JSON.Merge"; "[1,2,3]"; "[3,4,5]")
Example result:
[1, 2, 3, 4, 5]
Merge two objects:
MBS("JSON.Merge"; "{\"a\":1}"; "{\"b\":2}")
Example result:
{
"a": 1,
"b": 2
}
Merge two arrays with replacing a value:
MBS("JSON.Merge"; "{\"a\":1, \"c\":3}"; "{\"b\":2, \"c\":4}")
Example result:
{
"a": 1,
"c": 4,
"b": 2
}
Merge two objects with array:
MBS("JSON.Merge"; "{\"a\":[1,2], \"c\":3}"; "{\"a\":[3,4], \"b\":2, \"c\":4}")
Example result:
{
"a": [1, 2, 3, 4],
"c": 4,
"b": 2
}
Merge two object with object:
MBS("JSON.Merge"; "{\"a\":{\"a\":1}, \"c\":3}"; "{\"a\":{\"b\":2}, \"b\":2")
Example result:
{
"a": {
"a": 1,
"b": 2
},
"c": 3,
"b": 2
}
Merge four arrays:
MBS("JSON.Merge"; "[1,2,3]"; "[3,4,5]"; "[6,7]"; "[7,9]")
Example result:
[1, 2, 3, 4, 5, 6, 7, 9]
See also
Release notes
- Version 14.2
- Added JSON.Merge function.
- Version 14.0
- Added JSON.JSONPatch.ApplyPatch, JSON.JSONPatch.FromDiff, JSON.MergePatch.ApplyPatch and JSON.MergePatch.FromDiff functions.
Blog Entries
- Neues MBS Plugin 14.2 für Claris FileMaker
- MBS Plugin 14.2 for Claris FileMaker
- MBS FileMaker Plugin, version 14.2pr1
This function checks for a license.
Created 19th March 2024, last changed 19th March 2024