JSON Struct Generator

This tool generates VDF structs for a passed JSON string.


1. Add a custom prefix to your structs

2. Paste a valid JSON string here

3.

4.
Copy the generated structs to your VDF project!


Share

2 thoughts on JSON Struct Generator

  1. The tool makes an assumption that the contents of array are all the same “type”. In JSON, an array is just a list, which could be mixture of anything. The following JSON is valid.

    {
    “array” : [
    “property” : “value”
    “object” : {
    “property” : “value”
    }
    ]
    }

    Granted its not obvious how one would represent this as a struct, but the tool’s error message is misleading “Could not parse JSON. Use jsonlint.com to validate before trying again.”

    • Hi Paul,

      the reason it says “Could not parse JSON. Use jsonlint.com to validate before trying again” is because the input is infact not valid JSON. You’re missing commas to separate the array elements, for instance.

      I think this is what you’re after:

      You should try jsonlint.com (or any other tool) to validate your JSON string.

      And yes, just like you’re describing it’s hard to convert mixed array content types to a struct. At the moment it just looks at the first array element and assumes that all following are of the same type. What I can do is to change the mixed type parsing rule to a Variant[] instead. Would that be better?

Leave a Reply

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