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.5   7.0   7.1   7.2   7.3   7.4   7.5   8.0   8.1   8.2    Statistic  

JSON.AddItemToObject

Adds a new entry to the object with the given name and value.

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

MBS( "JSON.AddItemToObject"; json; name; json2 )

Parameters

Parameter Description Example value
json A JSON text or reference. {"key":"value"}
name The name of the Object property. "length"
json2 The JSON text for the item. 50

Result

Returns JSON code.

Description

Adds a new entry to the object with the given name and value.

With version 6, you can pass several parameters to add several entries to the object.
When adding to a JSON reference, the function returns that reference number.

Examples

Build nested objects:

Set Variable [$j1; MBS( "JSON.CreateObject") ]
Set Variable [$j2; MBS( "JSON.AddStringToObject"; $j1; "name"; "" ) ]
Set Variable [$j3; MBS( "JSON.AddStringToObject"; $j2; "record_type"; "MX" ) ]
Display Dialog ["JSON"; $j3]
Set Variable [$j4; MBS( "JSON.CreateObject") ]
Set Variable [$j5; MBS( "JSON.AddItemToObject"; $j4; "record"; $j3 ) ]
Display Dialog ["JSON"; $j4]

Add two items to an object:

MBS( "JSON.AddItemToObject"; "{}"; "Values"; "[1,2]"; "Name"; "{\"FirstName\":\"Heinz\"}" )

Example result:
  {
"Values": [1, 2],
"Name": {
"FirstName": "Heinz"
}
}

See also

Example Databases


JSON.AddItemToArray   -   JSON.AddNullToObject

Feedback: Report problem or ask question.




Links
MBS Xojo Plugins