Dictionary.ToJSON
-----------------

Returns JSON representation of dictionary for data exchange.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Dictionary](component_Dictionary.md) [JSON](component_JSON.md) | [6.1](newinversion61.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Dictionary.ToJSON"; DictionaryRef ) 

**MBS**( **"Dictionary.ToJSON";** /\* Returns JSON representation of dictionary for data exchange. \*/  
**$DictionaryRef**) /\* The reference number to the dictionary.e.g. $dic \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| DictionaryRef | The reference number to the dictionary. | $dic |

### Result

Returns JSON or error.

### Description

Returns JSON representation of dictionary for data exchange.  
This is useful for passing data from dictionary to some javascript.  
### Examples

Test exporting dictionaries:

 #   
\#   
\#Create new Dictionary   
\#   
Set Variable \[$param ; Value:MBS ( "[Dictionary.Create](DictionaryCreate.md)" )\]  
\#   
\#Fill in values   
\#   
Set Variable \[$r ; Value:MBS ( "[Dictionary.SetValueForKey](DictionarySetValueForKey.md)"; $param ; "text"; Pass Parameters with Dictionary::TextField )\]  
Set Variable \[$r ; Value:MBS ( "[Dictionary.SetValueForKey](DictionarySetValueForKey.md)"; $param ; "number"; Pass Parameters with Dictionary::NumberField )\]  
Set Variable \[$r ; Value:MBS ( "[Dictionary.SetValueForKey](DictionarySetValueForKey.md)"; $param ; "date"; Pass Parameters with Dictionary::DateField )\]  
Set Variable \[$r ; Value:MBS ( "[Dictionary.SetValueForKey](DictionarySetValueForKey.md)"; $param ; "time"; Pass Parameters with Dictionary::TimeField )\]  
Set Variable \[$r ; Value:MBS ( "[Dictionary.SetValueForKey](DictionarySetValueForKey.md)"; $param ; "timestamp"; Pass Parameters with Dictionary::TimeStampField )\]  
Set Variable \[$r ; Value:MBS ( "[Dictionary.SetValueForKey](DictionarySetValueForKey.md)"; $param ; "container"; Pass Parameters with Dictionary::ContainerField )\]  
\#   
\#Call save xml, json and text   
\#   
Set Variable \[$r ; Value:MBS ( "[Text.WriteTextFile](TextWriteTextFile.md)"; MBS ("[Dictionary.ToXML](DictionaryToXML.md)"; $param ; 1); MBS ( "[Path.AddPathComponent](PathAddPathComponent.md)"; MBS ( "[Folders.UserDesktop](FoldersUserDesktop.md)" ) ; "dictionary.xml"); "UTF8")\]  
Set Variable \[$r ; Value:MBS ( "[Text.WriteTextFile](TextWriteTextFile.md)"; MBS ("[Dictionary.ToText](DictionaryToText.md)"; $param ); MBS ( "[Path.AddPathComponent](PathAddPathComponent.md)"; MBS ( "[Folders.UserDesktop](FoldersUserDesktop.md)" ) ; "dictionary.txt"); "UTF8")\]  
Set Variable \[$r ; Value:MBS ( "[Text.WriteTextFile](TextWriteTextFile.md)"; MBS ("Dictionary.ToJSON"; $param ); MBS ( "[Path.AddPathComponent](PathAddPathComponent.md)"; MBS ( "[Folders.UserDesktop](FoldersUserDesktop.md)" ) ; "dictionary.json.txt"); "UTF8")\]  
\#   
\#free memory   
\#   
Set Variable \[$r ; Value:MBS ("[Dictionary.Release](DictionaryRelease.md)"; $param )\]  
### See also

- [Dictionary.AddSQLRecord](DictionaryAddSQLRecord.md)
- [Dictionary.AddSQLRecords](DictionaryAddSQLRecords.md)
- [Dictionary.Create](DictionaryCreate.md)
- [Dictionary.Lookup](DictionaryLookup.md)
- [Dictionary.Release](DictionaryRelease.md)
- [Dictionary.SetValueForKey](DictionarySetValueForKey.md)
- [Dictionary.ToXML](DictionaryToXML.md)
- [Folders.UserDesktop](FoldersUserDesktop.md)
- [Path.AddPathComponent](PathAddPathComponent.md)
- [Text.WriteTextFile](TextWriteTextFile.md)

### Release notes

- **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 11.0**
    - Fixed issue with [FM.SQL.JSONRecord](https://www.mbsplugins.eu/FMSQLJSONRecord.shtml), [FM.SQL.JSONRecords](https://www.mbsplugins.eu/FMSQLJSONRecords.shtml) and [Dictionary.ToJSON](https://www.mbsplugins.eu/DictionaryToJSON.shtml) where long numbers where truncated to double precision.

### Blog Entries

- [MBS FileMaker Advent calendar - Door 23 - Dictionary](https://www.mbsplugins.de/archive/2025-12-23/MBS_FileMaker_Advent_calendar_/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)
- [Neues MBS FileMaker Plugin 11.1](https://www.mbsplugins.de/archive/2021-03-09/Neues_MBS_FileMaker_Plugin_111/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 11.1](https://www.mbsplugins.de/archive/2021-03-09/MBS_FileMaker_Plugin_111/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 10.6pr3](https://www.mbsplugins.de/archive/2020-12-21/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)
- [Data structures in FileMaker with MBS Plugins](https://www.mbsplugins.de/archive/2017-10-19/Data_structures_in_FileMaker_w/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 6.1pr3](https://www.mbsplugins.de/archive/2016-02-25/MBS_FileMaker_Plugin_version_6/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 25th February 2016 , last changed 9th November 2021

  
[Dictionary.SetVariables](DictionarySetVariables.md) - [Dictionary.ToMatrix](DictionaryToMatrix.md)

[HTML Version](DictionaryToJSON.shtml)