Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old


Serialized a dictionary as a text.

Component Version macOS Windows Linux Server iOS SDK
Dictionary 5.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "Dictionary.Serialize"; DictionaryRef )   More


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


Returns text or error.


Serialized a dictionary as a text.
The dictionary content is stored in a base64 encoded string which the plugin function Dictionary.Deserialize 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 functions, SerialPort functions or by writing it to a file.


Create a dictionary and serialize it:

Set Variable [$list; Value:MBS( "Dictionary.Create"; "Hello"; "World"; "1234"; "Just a test!")]
Set Variable [$text; Value:MBS("Dictionary.Serialize"; $list)]
Set Variable [$SecondList; Value:MBS("Dictionary.Deserialize"; $text)]
Show Custom Dialog ["List"; "Encoded: " & $text & ¶ & ¶ & "Decoded Keys: " & MBS("Dictionary.Keys"; $secondList) & ¶ & ¶ & "D…]
Set Variable [$r; Value:MBS("Dictionary.Release"; $list)]
Set Variable [$r; Value:MBS("Dictionary.Release"; $secondList)]

Serialize and unserialize with date and time:

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

See also

Example Databases

Blog Entries

This function checks for a license.

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

Dictionary.RemoveKey - Dictionary.SetList