JSON.GetObjectItem
------------------

Queries named item from an object.

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

MBS( "JSON.GetObjectItem"; JSON; Name { ; AsReference } ) 

**MBS**( **"JSON.GetObjectItem";** /\* Queries named item from an object. \*/  
**$JSON**; /\* A JSON text or reference.e.g. "\[1,2,3\]" \*/   
**$Name**; /\* The name of the key to query.e.g. "test" \*/   
**$AsReference**) /\* Optional; Whether to return a reference number (1) instead of the JSON text (0).  
Default is 0 for JSON text.e.g. 0 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| JSON | A JSON text or reference. | "\[1,2,3\]" |  |
| Name | The name of the key to query. | "test" |  |
| AsReference | Whether to return a reference number (1) instead of the JSON text (0).   Default is 0 for JSON text. | 0 | Optional |

### Result

Returns JSON code.

### Description

Queries named item from an object.  
You still need functions like [JSON.GetStringValue](JSONGetStringValue.md) to get back the decoded string.  
### Examples

Create object, add content and pick value:

 Let(  
\[  
j = MBS ( "[JSON.CreateObject](JSONCreateObject.md)");  
j = MBS ( "[JSON.AddStringToObject](JSONAddStringToObject.md)"; j; "hello"; "world" );  
r = MBS ( "JSON.GetObjectItem"; j; "hello" )  
\];  
r)  
Pick a text from a JSON dictionary:

 Set Variable \[ $json ; Value: "{\\"first\\":\\"Christian\\",\\"last\\":\\"Schmitz\\",\\"city\\":\\"Nickenich\\"}" \]  
Set Variable \[ $first ; Value: MBS ("JSON.GetObjectItem"; $json ; "first") \]  
Set Variable \[ $firstText ; Value: MBS ("[JSON.GetStringValue](JSONGetStringValue.md)"; $first ) \]  
Show Custom Dialog \[ $firstText \]  
Extract error details from JSON:

 # JSON in field:   
\#{   
\# "error": {   
\# "message": "Your card's expiration year is invalid.",   
\# "type": "card\_error",   
\# "param": "exp\_year",   
\# "code": "invalid\_expiry\_year"   
\# }   
\#}   
\#get it in variable   
Set Variable \[$json ; Value:test::input \]  
\#pick error node   
Set Variable \[$error ; Value:MBS ("JSON.GetObjectItem"; $json ; "error")\]  
If \[$error = ""\]  
 Show Custom Dialog \["No error"; "No error node in the JSON."\]  
Else  
 #get message node  
 Set Variable \[$message ; Value:MBS ("JSON.GetObjectItem"; $error ; "message")\]  
 #decode text  
 Set Variable \[$messageText ; Value:MBS ("[JSON.GetStringValue](JSONGetStringValue.md)"; $message )\]  
 #get code node  
 Set Variable \[$code ; Value:MBS ("JSON.GetObjectItem"; $error ; "code")\]  
 #decode text  
 Set Variable \[$codeText ; Value:MBS ("[JSON.GetStringValue](JSONGetStringValue.md)"; $code )\]  
 #show result  
 Show Custom Dialog \["Got error"; "Message: " &amp; $messageText &amp; ¶ &amp; "Code: " &amp; $codeText \]  
End If  
### See also

- [FM.SQL.JSONRecords](FMSQLJSONRecords.md)
- [JSON.AddStringToObject](JSONAddStringToObject.md)
- [JSON.CreateObject](JSONCreateObject.md)
- [JSON.FindValueInObjectArray](JSONFindValueInObjectArray.md)
- [JSON.GetObjectItemTree](JSONGetObjectItemTree.md)
- [JSON.GetObjectItemTreeRef](JSONGetObjectItemTreeRef.md)
- [JSON.GetObjectName](JSONGetObjectName.md)
- [JSON.GetObjectSize](JSONGetObjectSize.md)
- [JSON.GetStringValue](JSONGetStringValue.md)
- [JSON.Release](JSONRelease.md)

### Release notes

- **Version 11.4**
    - Fixed a crash in [JSON.GetObjectItem](https://www.mbsplugins.eu/JSONGetObjectItem.shtml) with big JSON arrays.
- **Version 11.3**
    - Changed [JSON.GetObjectItemTree](https://www.mbsplugins.eu/JSONGetObjectItemTree.shtml), [JSON.GetObjectItemTreeRef](https://www.mbsplugins.eu/JSONGetObjectItemTreeRef.shtml), [JSON.AddArrayToArray](https://www.mbsplugins.eu/JSONAddArrayToArray.shtml) and [JSON.AddItemToArray](https://www.mbsplugins.eu/JSONAddItemToArray.shtml) to ignore empty parameters.

### Example Databases

- [CURL/Email/IMAP Email List](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/Email/IMAP%20Email%20List.shtml#1ScriptAnchor_)
- [CURL/Email/IMAP Email](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/Email/IMAP%20Email.shtml#1ScriptAnchor_)
- [CURL/WebServices/TinyURL](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/WebServices/TinyURL.shtml#1ScriptAnchor_)
- [CURL/WebServices/WeatherBit.io test](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/WebServices/WeatherBit.io%20test.shtml#3ScriptAnchor_)
- [JSON/JSON Order Parsing](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/JSON/JSON%20Order%20Parsing.shtml#1ScriptAnchor_)
- [JSON/JSON Test](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/JSON/JSON%20Test.shtml#2ScriptAnchor_)
- [Win Only/WindowsML](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Win%20Only/WindowsML.shtml#6ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 11.4pr4](https://www.mbsplugins.de/archive/2021-08-30/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [With JSON in excellent form](https://www.mbsplugins.de/archive/2019-11-16/With_JSON_in_excellent_form/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 5/2020, Seite 18](https://filemaker-magazin.de/neuigkeit/4110-Appetithappen-FMM_202005)

This function checks for a license.

Created 18th August 2014 , last changed 25th February 2026

  
[JSON.GetIntegerValue](JSONGetIntegerValue.md) - [JSON.GetObjectItemTree](JSONGetObjectItemTree.md)

[HTML Version](JSONGetObjectItem.shtml)