Access/VBA Library

DictionaryToJSON

Returns a String containing a JSON representation of a Dictionary.

Syntax

DictionaryToJSON( Data )
Parameters
Name Type Description
Data Dictionary Required. Data to be converted to JSON.
Return value

String : JSON representation of the Dictionary data.

Code
Public Function DictionaryToJSON(Data As Dictionary) As String
    
    Dim key
    Dim js As String
    Dim pfx As String
    
    js = "{"
    For Each key In Data.Keys
        Concat js, pfx, JSONdata(key, Data(key))
        pfx = ","
    Next key
    Concat js, "}"
    
    DictionaryToJSON = js
End Function

JSONtag:JSONDictionarytag:Dictionary

See also

  • JSONdata
  • Concat