FM.SQL.JSONColumn
-----------------

Returns a column as JSON array.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [FM](component_FM.md) [FMSQL](component_FMSQL.md) [JSON](component_JSON.md) | [10.5](newinversion105.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "FM.SQL.JSONColumn"; SQLref; Column { ; Flags } ) 

**MBS**( **"FM.SQL.JSONColumn";** /\* Returns a column as JSON array. \*/  
**$SQLref**; /\* The reference number returned by [FM.SQL.Execute](FMSQLExecute.md) function. \*/   
**$Column**; /\* The column index to use from the SQL result.e.g. 0 \*/   
**$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 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 |
|---|---|---|---|
| SQLref | The reference number returned by [FM.SQL.Execute](FMSQLExecute.md) function. | $SQLRef |  |
| Column | The column index to use from the SQL result. | 0 |  |
| 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 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 array or error.

### Description

Returns a column as JSON array.  
Optionally we can return SQL dates, times and timestamps as SQL format.  
Containers are returned as Base64 encoded data.  
### Examples

Query JSON array of all groups we have:

 Set Variable \[ $sql ; Value: MBS ("[FM.SQL.Execute](FMSQLExecute.md)"; ""; "SELECT DISTINCT \\"Group\\" FROM \\"Contacts\\" WHERE Length(\\"Group\\") &gt; 0") \]   
Set Variable \[ $values ; Value: MBS ("FM.SQL.JSONColumn"; $SQL ; 0) \]   
Set Variable \[ $r ; Value: MBS ("[FM.SQL.Release](FMSQLRelease.md)"; $SQL ) \]   
Show Custom Dialog \[ "Values" ; $values \]  
Query two JSON arrays, one for group names and ID list:

 Set Variable \[ $sql ; Value: MBS ("[FM.SQL.Execute](FMSQLExecute.md)"; ""; "SELECT DISTINCT \\"ID\\", \\"Group\\" FROM \\"Contacts\\" WHERE Length(\\"Group\\") &gt; 0") \]   
If \[ MBS ("IsError") \]   
 Show Custom Dialog \[ "Error" ; $sql \]   
Else  
 Set Variable \[ $IDs ; Value: MBS ("FM.SQL.JSONColumn"; $SQL ; 0) \]   
 Set Variable \[ $Groups ; Value: MBS ("FM.SQL.JSONColumn"; $SQL ; 1) \]   
 Set Variable \[ $r ; Value: MBS ("[FM.SQL.Release](FMSQLRelease.md)"; $SQL ) \]   
 Show Custom Dialog \[ "Values" ; $IDs &amp; ¶ &amp; $Groups \]   
End If  
### See also

- [FM.SQL.Execute](FMSQLExecute.md)
- [FM.SQL.Release](FMSQLRelease.md)
- [IsError](IsError.md)
- [SQL.Execute](SQLExecute.md)

### Release notes

- **Version 15.4**
    - Added DetectJSON flag to [FM.SQL.JSONColumn](https://www.mbsplugins.eu/FMSQLJSONColumn.shtml), [FM.SQL.JSONRecord](https://www.mbsplugins.eu/FMSQLJSONRecord.shtml) and [FM.SQL.JSONRecords](https://www.mbsplugins.eu/FMSQLJSONRecords.shtml).
- **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 12.0**
    - Fixed [JSON](https://www.mbsplugins.eu/component_JSON.shtml) functions to return NULL for numbers with no content, e.g. empty text. This affects [JSON.CreateNumber](https://www.mbsplugins.eu/JSONCreateNumber.shtml), [Dictionary.ToJSON](https://www.mbsplugins.eu/DictionaryToJSON.shtml), [FM.SQL.JSONColumn](https://www.mbsplugins.eu/FMSQLJSONColumn.shtml), [FM.SQL.JSONRecord](https://www.mbsplugins.eu/FMSQLJSONRecord.shtml) and [FM.SQL.JSONRecords](https://www.mbsplugins.eu/FMSQLJSONRecords.shtml) functions.
- **Version 10.5**
    - Added [FM.SQL.JSONColumn](https://www.mbsplugins.eu/FMSQLJSONColumn.shtml) function.

### Blog Entries

- [MBS FileMaker Advent calendar - Door 14 - SQL and JSON](https://www.mbsplugins.de/archive/2025-12-14/MBS_FileMaker_Advent_calendar_/monkeybreadsoftware_blog_filemaker)
- [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 11.6pr3](https://www.mbsplugins.de/archive/2021-12-14/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [New in MBS FileMaker Plugin 10.5](https://www.mbsplugins.de/archive/2020-11-23/New_in_MBS_FileMaker_Plugin_10/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 10.5pr2](https://www.mbsplugins.de/archive/2020-10-05/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 6/2020, Seite 26](https://filemaker-magazin.de/neuigkeit/4118-Appetithappen-FMM_202006)

This function checks for a license.

Created 2nd October 2020 , last changed 24th July 2025

  
[FM.SQL.InsertRecordsToSQL](FMSQLInsertRecordsToSQL.md) - [FM.SQL.JSONRecord](FMSQLJSONRecord.md)

[HTML Version](FMSQLJSONColumn.shtml)