JSON Dictionary

JSON objects in VDF

The cJSONDictionary is a specialized component for building and handling JSON in VDF. A cJSONDictionary instance can be created from a JSON string via the cJSONParser or be manually created. You can, at any point, serialize the containing key/value pairs to a JSON string containing child objects, arrays or whatever you decide to put in the cJSONDictionary.


Code example

Ok let's try to recreate this JSON object with the cJSONDictionary class and then serialize it to a nice JSON string.

Notice how JSON object nesting is achieved. If a value for a given key is an instance of a cJSONDictionary the Serialize function in the parent object will call the child cJSONDictionary's Serialize function recursively. This also works for cJSONDictionarys inside arrays.



One thought on “JSON Dictionary

  1. Erik – I get a runtime error when executing the MakeJSON procedure above

    the error occurs at line 44 of cHashTable.pkg

    using vdf 17.1 beta

    Illegal Datatype Conversion. Incompatible data type – Cannot convert array of ‘INTEGER[]’ to array of ‘VARIANT[]’

    Error: 4381

    MSG_PUT (10978) – oObject (1464) – at address 75158
    SET_VALUE (18) – oObject (1399) – at address 75289
    MSG_ONCLICK (4600) – oButton1 (237) – at address 75833
    MSG_COMMAND (648) – oButton1 (237) – in native code
    [start] – at address 75851

Leave a Reply

Your email address will not be published. Required fields are marked *