Skip to content

Creates Type.Object where list.Count and keys.Count are out of sync #47

@Cruncher999

Description

@Cruncher999

Trying to parse this incorrect JSON string:
{"Parent":{"MyFloat":12,8}}
does not result in an error. Instead, it returns a Type.Object where the sizes of list and keys differ (due to SafeAddChild() being called at some point). Is this something the user should expect and intercept/check in his code? My understanding is that a Type.Object is always a key/value pair, not just a key, so these List<>'s should always be the same size.

The source of that JSON test string is an incorrect export from some other tool (=localization misinterpretation of the value "12.8"). For "12,8", I'd expect maybe a partial JSON being returned (with MyFloat==12), but also yielding an error due to the dangling "8". I tried https://jsonformatter.curiousconcept.com/ , and it detects the error for all RFC specs.

A previous version of JSONObject we used (I think it was somewhere around 1.4) also did not throw an error, but did at least return a (syntactically) correct object:

{
	"Parent":{
		"MyFloat":12,
		"MyFloat":8
	}
}

The current version (6418374 from 2022/02/02) outputs this with JSONChecker:

{
	"Parent":{
		"MyFloat":12
	}
}

, but also does not indicate an error, therefore silently ignoring the incorrect "8", and returning the misaligned/unexpected JSONObject.

JSONChecker claims everything is fine, because Stringify() explicitly checks whether keys[index] is still in range, and simply bails out if it isn't.

EDIT: Further experimenting: This equally malformed JSON (=lhs of colon must not be a number):
{"Parent":{"MyFloat":12,8:""}}
is interpreted by JSONChecker as:

{
	"Parent":{
		"MyFloat":12,
		"MyFloat":""
	}
}

, without recognizing the error, and which is also an incorrect interpretation of the input string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions