Dictionary to string and back

BTW if anyone needs this functionality and wants my module I’m happy to pass along. It uses some MBS calls so may suffer some limitations if you must remove them.

1 Like

Just an FYI … you can actually store MemoryBlock and any other binary data in JSON by simply doing EncodeBase64() before GenerateJSON(), and doing DecodeBase64() after ParseJSON(). For example:

Var tmpDict As Dictionary = new Dictionary
Var tmpData As MemoryBlock =  (lots of binary data)
tmpDict.Value(“myBinaryData”) = EncodeBase64(tmpData)
Var json As String = GenerateJSON(tmpDict)

// Write the json to a file, then later read it back it and reverse ...
Var json As String = ParseJSON( rawJsonTextFromFile )
Var tmpDict As Dictionary = new Dictionary
Var myMemoryBlock As MemoryBlock = DecodeBase64( tmpDict.Value(“myBinaryData”) )
tmpDict = Dictionary(json)
1 Like

Of course, and that’s exactly what I do with my current XML solution. Ditto for folderItems, etc. With enough effort you can do most anything. My point was, I was hoping there would be a canned solution so we can just do the 2 calls as in my initial message with all these hacks opaque to the user.