Matrix.JSONRecord
-----------------

Returns a row as JSON object.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Matrix](component_Matrix.md) | [9.2](newinversion92.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Matrix.JSONRecord"; MatrixRef; Row; FieldNames { ; Flags } ) 

**MBS**( **"Matrix.JSONRecord";** /\* Returns a row as JSON object. \*/  
**$MatrixRef**; /\* The matrix reference number.e.g. $matrix \*/   
**$Row**; /\* The row you like to get.e.g. 1 \*/   
**$FieldNames**; /\* A list of field names for the JSON.  
If empty, we use column names, if you have some. (since 14.3)e.g. "Model¶Names" \*/   
**$Flags**) /\* Optional; The flags for the json creation.  
Add 1 to get all values as text.  
Add 2 to get all dates, times and timestamps in SQL format.  
Add 4 to get arrays instead of objects for the individual rows.  
Add 8 to get containers as objects with name, size and data entries. (new in v12.1)  
Add 32 to detect JSON in text values and return the JSON inline. (New in v15.4)e.g. 1+2 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| MatrixRef | The matrix reference number. | $matrix |  |
| Row | The row you like to get. | 1 |  |
| FieldNames | A list of field names for the JSON.   If empty, we use column names, if you have some. (since 14.3) | "Model¶Names" |  |
| Flags | The flags for the json creation.   Add 1 to get all values as text.   Add 2 to get all dates, times and timestamps in SQL format.   Add 4 to get arrays instead of objects for the individual rows.   Add 8 to get containers as objects with name, size and data entries. (new in v12.1)   Add 32 to detect JSON in text values and return the JSON inline. (New in v15.4) | 1+2 | Optional |

### Result

Returns JSON text or error.

### Description

Returns a row as JSON object.  
You provide list of field names, which should be in same order as fields in matrix.  
Optionally we can return SQL dates, times and timestamps as SQL format.  
Containers are returned as Base64 encoded data.  
### Examples

Query JSON:

 Set Variable \[ $JSON ; Value: MBS ( "Matrix.JSONRecord"; $result ; 1; "a¶b¶c" ) \]  
### See also

- [Matrix.CSVSplit](MatrixCSVSplit.md)
- [Matrix.JSONRecords](MatrixJSONRecords.md)

### Release notes

- **Version 15.4**
    - Added DetectJSON flag to [Matrix.JSONRecord](https://www.mbsplugins.eu/MatrixJSONRecord.shtml) and [Matrix.JSONRecords](https://www.mbsplugins.eu/MatrixJSONRecords.shtml).
- **Version 14.3**
    - Changed [Matrix.JSONRecord](https://www.mbsplugins.eu/MatrixJSONRecord.shtml) and [Matrix.JSONRecords](https://www.mbsplugins.eu/MatrixJSONRecords.shtml) to take field names from column names, if you have some and you don't pass field names.
- **Version 14.2**
    - Added firstRow and lastRow parameter to [Matrix.JSONRecords](https://www.mbsplugins.eu/MatrixJSONRecords.shtml) function.
    - Added flag 16 for [Matrix.JSONRecords](https://www.mbsplugins.eu/MatrixJSONRecords.shtml) to include field names as first row if outputting arrays.
- **Version 12.2**
    - Added AsArray flag 4 for [Matrix.JSONRecord](https://www.mbsplugins.eu/MatrixJSONRecord.shtml) and [Matrix.JSONRecords](https://www.mbsplugins.eu/MatrixJSONRecords.shtml) functions.
- **Version 12.1**
    - Added flag value 8 for [FM.SQL.JSONColumn](https://www.mbsplugins.eu/FMSQLJSONColumn.shtml), [Matrix.JSONRecord](https://www.mbsplugins.eu/MatrixJSONRecord.shtml), [Matrix.JSONRecords](https://www.mbsplugins.eu/MatrixJSONRecords.shtml), [FM.SQL.JSONRecord](https://www.mbsplugins.eu/FMSQLJSONRecord.shtml) and [FM.SQL.JSONRecords](https://www.mbsplugins.eu/FMSQLJSONRecords.shtml) to return containers as JSON objects with data, size and name.
- **Version 11.1**
    - Fixed memory leak in [FM.SQL.JSONRecord](https://www.mbsplugins.eu/FMSQLJSONRecord.shtml) and [Matrix.JSONRecord](https://www.mbsplugins.eu/MatrixJSONRecord.shtml) functions.

### Blog Entries

- [MBS FileMaker Plugin, version 15.4pr1](https://www.mbsplugins.de/archive/2025-08-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 14.3pr2](https://www.mbsplugins.de/archive/2024-06-10/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [CSV in FileMaker with MBS FileMaker Plugin](https://www.mbsplugins.de/archive/2022-10-11/CSV_in_FileMaker_with_MBS_File/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 12.2pr6](https://www.mbsplugins.de/archive/2022-05-10/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 11.1pr2](https://www.mbsplugins.de/archive/2021-02-05/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 8th April 2019 , last changed 24th July 2025

  
[Matrix.InsertRow](MatrixInsertRow.md) - [Matrix.JSONRecords](MatrixJSONRecords.md)

[HTML Version](MatrixJSONRecord.shtml)