JKI-JSON-Serialization icon indicating copy to clipboard operation
JKI-JSON-Serialization copied to clipboard

Incorrect parsing of empty strings as object member names

Open JKSH opened this issue 7 years ago • 1 comments

Version 1.1.10.37

For fun, I unflattened the convoluted document from my comment in #26:

{
	"": {
		"": [
			{
				"": "",
				"txDefinition": {
					"repeatRate": 0,
					"canPort": 0,
					"messageId": 0
				}
			}
		]
	}
}

When I re-flatten this again, I get:

[
        [
        [
                        [
                "",
                {
                    "repeatRate":0,
                    "canPort":0,
                    "messageId":0
                }
            ]
        ]
    ]
]

Objects have been transformed into arrays.

Also, notice the weird indentation of the innermost and 2nd-innermost arrays at the output.


The output is correct if I replace the empty names ("") with non-empty ones.

See https://stackoverflow.com/questions/33254385/can-a-json-name-value-pair-have-an-empty-name -- Empty strings are valid names for object members.

JKSH avatar Aug 29 '17 10:08 JKSH

@JKSH For what it's worth, I think we've resolved the "weird indentation" issue #31

jimkring avatar Sep 20 '17 14:09 jimkring