This project is read-only.

Proposal to allow the JSON parser multiple properties


After investigation, instead of appending an arbitrary string to properties that exist multiple times in the KSP save files, how about they get parsed into JSON arrays? I think this will ease the work for API consumers, although as far as I can see right now it would require some magical values, for which properties actually are arrays, and which are just parsed as arrays. Another possible solution would be to parse any property with multiple entries into a 'special' structure and shielding that from API consumers a bit.

So if we have a part in a vessel like so:
attN = bottom, 2
attN = top, 0
The first solution would require somehow keeping track of what properties allow multiple entries and which are actually real arrays and parse this to
{ "part": {
        "attN": [ [ "bottom", 2 ], [ "top", 0 ] ]
} }
The second solution would parse this into a special structure somehow denoting this is a workaround.
{ "part": {
        "attN": {
            "workaround": true,
            "entries": [ [ "bottom", 2 ], [ "top", 0 ] ]
} }
I think the first solution can be implemented in the current codebase easier, in pretty much the same way and place the existing workaround is implemented. For the second solution, a new Newtonsoft.JSON.LINQ.JWorkAroundArray or so could be created, allowing existing code for adding attN or other properties to vessels to keep working.