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:
9.5
10.0
10.1
10.2
10.3
10.4
10.5
11.0
11.1
11.2
Statistic
FMM
Blog
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 |
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 |
Returns JSON code.
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"
}
Created 18th August 2014, last changed 11st December 2016
JSON.AddStringToArray - JSON.AddTrueToObject
Feedback: Report problem or ask question.