[1896] VRCJson.TryDeserializeFromJson may incorrectly parse braces in strings inside nested objects
ureishi
Tested with VRChat client build 1896.
I would like to report an issue with VRCJson.TryDeserializeFromJson.
There appear to be cases where valid JSON fails to deserialize when an object is nested two or more levels deep and a string inside the nested object contains a brace character (
{
or }
).The exact behavior appears to depend on the nesting depth and the brace character. It is not the case that every brace inside every nested object fails.
For example, a closing brace (
}
) inside a string at the third nesting level can deserialize successfully.Braces inside JSON strings should always be treated as ordinary string characters and should not affect the surrounding object structure.
The following valid JSON objects fail to deserialize:
{ "x": { "y": "{" } }
{ "x": { "y": "}" } }
{ "x": { "y": { "z": "{" } } }
Reproduction code:
string json1 = @"{ ""x"": { ""y"": ""{"" } }";
bool success1 =
VRCJson.TryDeserializeFromJson(json1, out DataToken result1);
Debug.Log(success1);
Debug.Log(result1.ToString());
// Expected: true
// Actual: false
//
// UnableToParse: Unable to Deserialize from Json:
// Found end of string before finishing object
string json2 = @"{ ""x"": { ""y"": ""}"" } }";
bool success2 =
VRCJson.TryDeserializeFromJson(json2, out DataToken result2);
Debug.Log(success2);
Debug.Log(result2.ToString());
// Expected: true
// Actual: false
//
// UnableToParse: Unable to Deserialize from Json:
// Found unexpected character '"' while looking for character ','
string json3 = @"{ ""x"": { ""y"": { ""z"": ""{"" } } }";
bool success3 =
VRCJson.TryDeserializeFromJson(json3, out DataToken result3);
Debug.Log(success3);
Debug.Log(result3.ToString());
// Expected: true
// Actual: false
//
// UnableToParse: Unable to Deserialize from Json:
// Found end of string before finishing object
// Control case: this valid JSON deserializes successfully.
string control = @"{ ""x"": { ""y"": { ""z"": ""}"" } } }";
bool controlSuccess =
VRCJson.TryDeserializeFromJson(control, out DataToken controlResult);
Debug.Log(controlSuccess);
Debug.Log(controlResult.ToString());
// Expected: true
// Actual: true
This may be related to the previously reported issue:
"VRCJson.TryDeserializeFromJson may still incorrectly parse arrays when strings contain brackets"
That report is marked complete, but similar parsing failures remain reproducible with braces inside string values in nested JSON objects in client build 1896.
Log In