JSON.GetArrayPathItems
----------------------

Queries value from JSON path in array of objects.

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

MBS( "JSON.GetArrayPathItems"; JSON; Path { ; AsValue } ) 

**MBS**( **"JSON.GetArrayPathItems";** /\* Queries value from JSON path in array of objects. \*/  
**$JSON**; /\* A JSON text or reference.  
If that is not an array, the function returns an empty result.e.g. "\[{\\"first\\":\\"Christian\\",\\"last\\":\\"Schmitz\\",\\"city\\":\\"Nickenich\\"}\]" \*/   
**$Path**; /\* The path through the json hierarchy as list.  
For object, pass name of item to choose. For array pass index.e.g. "last" \*/   
**$AsValue**) /\* Optional; Pass 1 to return as value, e.g. text or number.  
Pass 0 (or nothing) to return as JSON. \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| JSON | A JSON text or reference.   If that is not an array, the function returns an empty result. | "\[{\\"first\\":\\"Christian\\",\\"last\\":\\"Schmitz\\",\\"city\\":\\"Nickenich\\"}\]" |  |
| Path | The path through the json hierarchy as list.   For object, pass name of item to choose. For array pass index. | "last" |  |
| AsValue | Pass 1 to return as value, e.g. text or number.   Pass 0 (or nothing) to return as JSON. |  | Optional |

### Result

Returns value or error.

### Description

Queries value from JSON path in array of objects.  
The path describes the way through the hierarchy to find the JSON node to return.  
Result can be JSON or the value.  
### Examples

Query all test values in objects in array:

 MBS ("JSON.GetArrayPathItems"; JSON Test::JSON ; "test")  
Lookup items in array:

 MBS ( "JSON.GetArrayPathItems"; "\[{\\"first\\":\\"Christian\\",\\"last\\":\\"Schmitz\\",\\"city\\":\\"Nickenich\\"}, {\\"first\\":\\"Peter\\",\\"last\\":\\"Miller\\",\\"city\\":\\"New York\\"}\]"; "first"; 0 )  
<small>  
Example result:   
"Christian"  
"Peter"</small>Lookup item values in array:

 MBS ( "JSON.GetArrayPathItems"; "\[{\\"first\\":\\"Christian\\",\\"last\\":\\"Schmitz\\",\\"city\\":\\"Nickenich\\"}, {\\"first\\":\\"Peter\\",\\"last\\":\\"Miller\\",\\"city\\":\\"New York\\"}\]"; "first"; 1 )  
<small>  
Example result:   
Christian  
Peter</small>Lookup value in sub item:

 MBS ( "JSON.GetArrayPathItems"; "\[{\\"addresses\\": {\\"first\\":\\"Christian\\",\\"last\\":\\"Schmitz\\",\\"city\\":\\"Nickenich\\"}}\]"; "addresses¶first"; 1 )  
<small>  
Example result: Christian</small>### See also

- [JSON.GetArrayItem](JSONGetArrayItem.md)
- [JSON.GetArrayItems](JSONGetArrayItems.md)

### Release notes

- **Version 7.1**
    - Added [JSON.GetArrayPathItems](http://www.mbsplugins.eu/JSONGetArrayPathItems.shtml) function.

### Blog Entries

- [MBS FileMaker Plugin, version 7.1pr1](https://www.mbsplugins.de/archive/2017-02-04/MBS_FileMaker_Plugin_version_7/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 27th January 2017 , last changed 8th April 2024

  
[JSON.GetArrayItemsAsQuickList](JSONGetArrayItemsAsQuickList.md) - [JSON.GetArraySize](JSONGetArraySize.md)

[HTML Version](JSONGetArrayPathItems.shtml)