Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server (Not)   Client   Old   Guides   Examples
New in version: 6.1   6.2   6.3   6.4   6.5   7.0   7.1   7.2   7.3   7.4    Statistic  

Dictionary.Serialize

Serialized a dictionary as a text.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
Dictionary 5.2 Yes Yes Yes Yes Yes

MBS( "Dictionary.Serialize"; DictionaryRef )

Parameters

Parameter Description Example value
DictionaryRef The reference number to the dictionary as returned by Dictionary.Create function. $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 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.

Examples

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


Dictionary.RemoveKey   -   Dictionary.SetList

Feedback: Report problem or ask question.




Links
MBS Xojo blog