Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server (Not)   Client   Old   Guides   Examples
New in version: 6.3   6.4   6.5   7.0   7.1   7.2   7.3   7.4   7.5   7.6    Statistic  

JSON.SetPathItem

Sets a value in a JSON hierarchy.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
JSON 6.1 Yes Yes Yes Yes Yes

MBS( "JSON.SetPathItem"; json; Path; Value )

Parameters

Parameter Description Example value
json A JSON text or reference. "[1,2,3]"
Path The path through the json hierarchy as list.
For object, pass name of item to choose. For array pass index.
For last array you can use special value "append" to add an entry.
"people¶0¶last"
Value The new value as JSON. "\"Hello\""

Result

Returns JSON or error.

Description

Sets a value in a JSON hierarchy.
The path describes the way through the hierarchy to find the JSON node to return.
Please pass in new value as JSON.

Examples

Adds an entry with country:

MBS( "JSON.SetPathItem"; "{\"people\":[{\"first\":\"Christian\",\"last\":\"Schmitz\",\"city\":\"Nickenich\"}]}"; "people¶0¶country"; "\"Germany\"")

Example result:
  {
"people": [{
"first": "Christian",
"last": "Schmitz",
"city": "Nickenich",
"country": "Germany"
}]
}

Sets an entry in an array:

MBS( "JSON.SetPathItem"; "[1,2,3]"; "1"; 5)

Example result: [1, 5, 3]

Adds an entry to array in object:

MBS( "JSON.SetPathItem"; "{\"test\":[1,2,3]}"; "test¶append"; 5)

Example result:
  {
"test": [1, 2, 3, 5]
}

See also


JSON.ReplaceItemInObject   -   Java.CallObjectMethod

Feedback: Report problem or ask question.




Links
MBS FileMaker tutorial videos