Access/VBA Library

ArrayToJSON

Returns a String containing a JSON representation of an Array.

Syntax

ArrayToJSON( Data )
Parameters
Name Type Description
Data Variant Required. Array to be converted to JSON.
Return value

String : JSON representation of the Array data.

Code
Public Function ArrayToJSON(Data) As String
    Dim pfx As String
    Dim i As Long
    Dim js As String
    
    js = "["
    
    For i = LBound(Data) To UBound(Data)
        Concat js, pfx, JSONvalue(Data(i))
        pfx = ","
    Next i
    Concat js, "]"
    
    ArrayToJSON = js

End Function

JSONtag:JSONArraytag:Array

See also

  • JSONvalue
  • Concat