Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples   Videos
New in version: 10.3   10.4   10.5   11.0   11.1   11.2   11.3   11.4   11.5   11.6    Statistic    FMM    Blog  

JSON.AddStringToObject

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

Component Version macOS Windows Linux Server iOS SDK
JSON 2.7 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "JSON.AddStringToObject"; json; Name...; Value... )   More

Parameters

Parameter Description Example
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.

This function takes variable number of parameters. Pass as much parameters as needed separated by the semicolon in FileMaker.
Please repeat Name and Value parameters as often as you need.

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

Example Databases

Blog Entries

FileMaker Magazin

Created 18th August 2014, last changed 5th June 2021


JSON.AddStringToArray - JSON.AddTrueToObject

Feedback: Report problem or ask question.




Links
MBS Xojo blog

Start Chat