JSON.AddStringToObject
----------------------

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

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [JSON](component_JSON.md) | [2.7](newinversion27.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "JSON.AddStringToObject"; JSON; Name...; Value... ) 

**MBS**( **"JSON.AddStringToObject";** /\* Adds a new entry to the object with the given name and value. \*/  
**$JSON**; /\* A JSON text or reference.e.g. {"key": "value"} \*/   
**$Name...**; /\* The name of the Object property.e.g. "length" \*/   
**$Value...**) /\* The text value to add.e.g. "Hello \*/ 

### 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](JSONCreateObject.md)");  
 j = MBS ( "JSON.AddStringToObject"; j; "hello"; "world" );  
 r = MBS ( "[JSON.GetObjectItem](JSONGetObjectItem.md)"; j; "hello" )  
\];  
r)  
<small>  
Example result: "world"</small>Build nested objects:

 Set Variable \[$j1 ; MBS ( "[JSON.CreateObject](JSONCreateObject.md)") \]  
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](JSONCreateObject.md)") \]  
Set Variable \[$j5 ; MBS ( "[JSON.AddItemToObject](JSONAddItemToObject.md)"; $j4 ; "record"; $j3 ) \]  
Display Dialog \["JSON"; $j4 \]  
Add two entries in one call:

 MBS ( "JSON.AddStringToObject"; "{}"; "hello"; "world"; "test"; "entry")  
<small>  
Example result:   
{ "hello" : "world" , "test" : "entry" } </small>Adds string to object:

 MBS ( "JSON.AddStringToObject"; "{}"; "test"; "Hello World" )  
<small>  
Example result:   
{ "test" : "Hello World" } </small>### See also

- [JSON.AddItemToArray](JSONAddItemToArray.md)
- [JSON.AddItemToObject](JSONAddItemToObject.md)
- [JSON.AddNumberToObject](JSONAddNumberToObject.md)
- [JSON.AddStringToArray](JSONAddStringToArray.md)
- [JSON.AddValueToObject](JSONAddValueToObject.md)
- [JSON.CreateArrayRef](JSONCreateArrayRef.md)
- [JSON.CreateObjectRef](JSONCreateObjectRef.md)
- [MapView.AddPoint](MapViewAddPoint.md)
- [MapView.Snapshot](MapViewSnapshot.md)
- [SQL.SetParamsWithJSON](SQLSetParamsWithJSON.md)

### Example Databases

- [CURL/WebServices/CURL FMS Admin API v17](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/WebServices/CURL%20FMS%20Admin%20API%20v17.shtml#1ScriptAnchor_)
- [CURL/WebServices/CURL FMS Admin API v18](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/WebServices/CURL%20FMS%20Admin%20API%20v18.shtml#27ScriptAnchor_)
- [Files/FileOperation](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Files/FileOperation.shtml#7ScriptAnchor_)
- [Mac and iOS/MapKit/MapKit Snapshots](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/MapKit/MapKit%20Snapshots.shtml#1ScriptAnchor_)
- [Mac and iOS/MapKit/MapView BeeExample](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/MapKit/MapView%20BeeExample.shtml#3ScriptAnchor_)
- [SQL to other databases/SQLite fun](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SQL%20to%20other%20databases/SQLite%20fun.shtml#5ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Advent calendar - Door 15 - vCard QR](https://www.mbsplugins.de/archive/2024-12-15/MBS_FileMaker_Advent_calendar_/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Advent calendar - Door 11 - Know Your Way](https://www.mbsplugins.de/archive/2024-12-11/MBS_FileMaker_Advent_calendar_/monkeybreadsoftware_blog_filemaker)
- [Recursive Folder Copy Script](https://www.mbsplugins.de/archive/2021-11-12/Recursive_Folder_Copy_Script/monkeybreadsoftware_blog_filemaker)
- [With JSON in excellent form](https://www.mbsplugins.de/archive/2019-11-16/With_JSON_in_excellent_form/monkeybreadsoftware_blog_filemaker)
- [Generate JSON with MBS Plugin](https://www.mbsplugins.de/archive/2013-12-03/Generate_JSON_with_MBS_Plugin/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 3/2022, Seite 27](https://filemaker-magazin.de/neuigkeit/4187-Appetithappen-FMM_202203)
- [Ausgabe 3/2022, Seite 24](https://filemaker-magazin.de/neuigkeit/4187-Appetithappen-FMM_202203)
- [Ausgabe 5/2020, Seite 16](https://filemaker-magazin.de/neuigkeit/4110-Appetithappen-FMM_202005)

This function checks for a license.

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

  
[JSON.AddStringToArray](JSONAddStringToArray.md) - [JSON.AddTrueToObject](JSONAddTrueToObject.md)

[HTML Version](JSONAddStringToObject.shtml)