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   8.0    Statistic  

JSON.AddStringToObject

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.AddStringToObject"; json; name; value )

Parameters

Parameter Description Example value
json A JSON text or reference. {"key": "value"}
name The name of the Object property. "length"
value The text value to add. "Hello

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

Create object, add content and pick value:

Let(
[
      j = MBS( "JSON.CreateObject");
      j = MBS( "JSON.AddStringToObject"; j; "hello"; "world" );
      r = MBS( "JSON.GetObjectItem"; j; "hello" )
];
r)

Example result: "world"

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 entries in one call:

MBS( "JSON.AddStringToObject"; "{}"; "hello"; "world"; "test"; "entry")

Example result:
  {
"hello": "world",
"test": "entry"
}

Adds string to object:

MBS( "JSON.AddStringToObject"; "{}"; "test"; "Hello World" )

Example result:
  {
"test": "Hello World"
}

See also


JSON.AddStringToArray   -   JSON.AddTrueToObject

Feedback: Report problem or ask question.




Links
MBS Xojo Plugins