Dictionary.Serialize
--------------------

Serialized a dictionary as a text.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Dictionary](component_Dictionary.md) | [5.2](newinversion52.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Dictionary.Serialize"; DictionaryRef ) 

**MBS**( **"Dictionary.Serialize";** /\* Serialized a dictionary as a text. \*/  
**$DictionaryRef**) /\* The reference number to the dictionary.e.g. $dic \*/ 

### Parameters

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

### Result

Returns text or error.

### Description

Serialized a dictionary as a text.  
The dictionary content is stored in a base64 encoded string which the plugin function [Dictionary.Deserialize](DictionaryDeserialize.md) can read.  
Does not work with external containers.  
Using this function allows to store a dictionary in a text field or transmit it with [Socket](component_Socket.md) functions, [SerialPort](component_SerialPort.md) functions or by writing it to a file.  
### Examples

Create a dictionary and serialize it:

 Set Variable \[$list ; Value:MBS ( "[Dictionary.Create](DictionaryCreate.md)"; "Hello"; "World"; "1234"; "Just a test!")\]  
Set Variable \[$text ; Value:MBS ("Dictionary.Serialize"; $list )\]  
Set Variable \[$SecondList ; Value:MBS ("[Dictionary.Deserialize](DictionaryDeserialize.md)"; $text )\]  
Show Custom Dialog \["List"; "Encoded: " &amp; $text &amp; ¶ &amp; ¶ &amp; "Decoded Keys: " &amp; MBS ("[Dictionary.Keys](DictionaryKeys.md)"; $secondList ) &amp; ¶ &amp; ¶ &amp; "D…\]  
Set Variable \[$r ; Value:MBS ("[Dictionary.Release](DictionaryRelease.md)"; $list )\]  
Set Variable \[$r ; Value:MBS ("[Dictionary.Release](DictionaryRelease.md)"; $secondList )\]  
Serialize and unserialize with date and time:

 # Create Dictionary   
Set Variable \[$dict ; Value:MBS ( "[Dictionary.Create](DictionaryCreate.md)" )\]  
\# put date and time inside:   
Set Variable \[$r ; Value:MBS ( "[Dictionary.SetValueForKey](DictionarySetValueForKey.md)"; $dict ; "theTime"; Get ( CurrentTime ))\]  
Set Variable \[$r ; Value:MBS ( "[Dictionary.SetValueForKey](DictionarySetValueForKey.md)"; $dict ; "theDate"; Get ( CurrentDate ))\]  
\# Serialize this   
Set Variable \[$dictEncoded ; Value:MBS ( "Dictionary.Serialize"; $dict )\]  
\#Free dictionary   
Set Variable \[$r ; Value:MBS ( "[Dictionary.Release](DictionaryRelease.md)"; $dict )\]  
\# Unpack it:   
Set Variable \[$newDict ; Value:MBS ( "[Dictionary.Deserialize](DictionaryDeserialize.md)"; $dictEncoded )\]  
\# and get values   
Set Variable \[$TheTime ; Value: MBS ( "[Dictionary.ValueForKey](DictionaryValueForKey.md)"; $newDict ; "theTime" )\]  
Set Variable \[$TheDate ; Value: MBS ( "[Dictionary.ValueForKey](DictionaryValueForKey.md)"; $newDict ; "theDate" )\]  
Show Custom Dialog \[$TheTime &amp; " " &amp; $TheDate \]  
Set Variable \[$r ; Value:MBS ( "[Dictionary.Release](DictionaryRelease.md)"; $newDict )\]  
### See also

- [Dictionary.Create](DictionaryCreate.md)
- [Dictionary.Deserialize](DictionaryDeserialize.md)
- [Dictionary.Keys](DictionaryKeys.md)
- [Dictionary.Release](DictionaryRelease.md)
- [Dictionary.SetValueForKey](DictionarySetValueForKey.md)
- [Dictionary.ValueForKey](DictionaryValueForKey.md)

### Example Databases

- [Dictionary/Dictionary Container Test](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Dictionary/Dictionary%20Container%20Test.shtml#2ScriptAnchor_)

### Blog Entries

- [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)
- [MBS FileMaker Plugin, version 5.2pr6](https://www.mbsplugins.de/archive/2015-07-10/MBS_FileMaker_Plugin_version_5/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 6th July 2015 , last changed 1st March 2021

  
[Dictionary.RemoveKey](DictionaryRemoveKey.md) - [Dictionary.SetList](DictionarySetList.md)

[HTML Version](DictionarySerialize.shtml)