SQL.GetFieldsAsJSON
-------------------

Queries fields values current record as JSON object.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [SQL](component_SQL.md) | [10.2](newinversion102.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "SQL.GetFieldsAsJSON"; Command ) 

**MBS**( **"SQL.GetFieldsAsJSON";** /\* Queries fields values current record as JSON object. \*/  
**$Command**) /\* The command reference number gained with [SQL.NewCommand](SQLNewCommand.md). \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| Command | The command reference number gained with [SQL.NewCommand](SQLNewCommand.md). | $Command |

### Result

Returns JSON or error.

### Description

Queries fields values current record as JSON object.  
Dates, Intervals and BLOBs get converted to text. Boolean, Integer, Numeric and Double types are converted to numbers in JSON. Boolean is passed through as boolean. Null or unknown field types are returned as NULL in JSON.  
### Examples

Show records as JSON:

 # Create select and run it   
Set Variable \[ $Command ; Value: MBS ("[SQL.NewCommand](SQLNewCommand.md)"; $Connection ; "SELECT \* FROM Test") \]   
\# Run it   
Set Variable \[ $result ; Value: MBS ("[SQL.Execute](SQLExecute.md)"; $Command ) \]   
If \[ $result ≠ "OK" \]   
 Show Custom Dialog \[ "Error: " &amp; $result \]   
Else  
 Loop  
 Set Variable \[ $result ; Value: MBS ("[SQL.FetchNext](SQLFetchNext.md)"; $Command ) \]   
 Exit Loop If \[ $result ≠ 1 \]   
 Show Custom Dialog \[ "JSON" ; MBS ( "SQL.GetFieldsAsJSON"; $Command ) \]   
 End Loop  
End If  
\# Cleanup   
Set Variable \[ $result2 ; Value: MBS ("[SQL.FreeCommand](SQLFreeCommand.md)"; $Command ) \]  
### See also

- [SQL.Execute](SQLExecute.md)
- [SQL.FetchNext](SQLFetchNext.md)
- [SQL.FreeCommand](SQLFreeCommand.md)
- [SQL.GetFieldAsJPEG](SQLGetFieldAsJPEG.md)
- [SQL.GetFieldAsPDF](SQLGetFieldAsPDF.md)
- [SQL.GetFieldAsPNG](SQLGetFieldAsPNG.md)
- [SQL.GetFieldAsText](SQLGetFieldAsText.md)
- [SQL.GetFieldAsTime](SQLGetFieldAsTime.md)
- [SQL.GetRecordsAsJSON](SQLGetRecordsAsJSON.md)
- [SQL.NewCommand](SQLNewCommand.md)

### Release notes

- **Version 10.2**
    - Added [SQL.GetFieldsAsJSON](https://www.mbsplugins.eu/SQLGetFieldsAsJSON.shtml), [SQL.GetParamsAsJSON](https://www.mbsplugins.eu/SQLGetParamsAsJSON.shtml), [SQL.GetRecordsAsJSON](https://www.mbsplugins.eu/SQLGetRecordsAsJSON.shtml) and [SQL.SetParamsWithJSON](https://www.mbsplugins.eu/SQLSetParamsWithJSON.shtml) functions.

### Example Databases

- [SQL to other databases/SQLite fun](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SQL%20to%20other%20databases/SQLite%20fun.shtml#7ScriptAnchor_)

### Blog Entries

- [Embrace JSON](https://www.mbsplugins.de/archive/2020-09-29/Embrace_JSON/monkeybreadsoftware_blog_filemaker)
- [News about the MBS FileMaker Plugin 10.2](https://www.mbsplugins.de/archive/2020-05-19/News_about_the_MBS_FileMaker_P/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 10.2pr1](https://www.mbsplugins.de/archive/2020-04-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function is free to use.

Created 11st March 2020 , last changed 11st March 2020

  
[SQL.GetFieldValueList](SQLGetFieldValueList.md) - [SQL.GetIsolationLevel](SQLGetIsolationLevel.md)

[HTML Version](SQLGetFieldsAsJSON.shtml)