Braces inside strings in VRCJSON can fail to deserialize.
complete
vavassor
VRChat SDK version 3.2.0
Newtonsoft Json version 2.0.2
VRCJson.TryDeserializeFromJson("{\"key\":{\"nestedKey\":\"{\"}}", out DataToken token)
returns false. Braces are valid inside a string value in JSON, so it should return true.Log In
syncpulse
Still seems broken in the SDK, ver 3.7.4?
Phasedragon
complete
Fixed in 2024.4.1p3
syncpulse
every time i start a new project i am abruptly reminded that this bug still exists. pls 2 fix plzzzzplzplz
Haxy
Still an issue.
LED Lamp
you can work around by encoding them
Fusl
Merged in a post:
JSON with closing-bracket inside string fails to decode properly
Haxy
Decoding a block of json that contains a closing brace in one of the lower layers results in very broken loading behaviour where anything previously in the file is ignored, and anything after the current layer is ignored
Anything past the closing bracket and before the next layer in the json is decoded and returned as wrongfully layered data
Repro:
[[["1","2","3"],["foo","]bar","baz"]],["a","b","c"]]
String jsonDecoderGoBang = "[[[\"1\",\"2\",\"3\"],[\"foo\",\"]bar\",\"baz\"]],[\"a\",\"b\",\"c\"]]";
var success = VRCJson.TryDeserializeFromJson(jsonDecoderGoBang, out DataToken testData);
if (!success)
{
Debug.LogError("Failed to deserialize json "+testData.Error);
}
if (testData.TokenType == TokenType.DataDictionary)
{
Debug.Log($"Successfully deserialized as a dictionary with {testData.DataDictionary.Count} items.");
}
else if (testData.TokenType == TokenType.DataList)
{
Debug.Log($"Successfully deserialized as a list with {testData.DataList.Count} items.");
}
Successfully deserialized as a list with 1 items.
vavassor
Oddly, balanced braces work perfectly fine. For example,
VRCJson.TryDeserializeFromJson("{\"key\":{\"nestedKey\":\"{{}}{{{}}}\"}}", out DataToken token)
returns true.vavassor
The reason I came across this is I was making a localization file format for a world. In order to do interpolation/string formatting, I was writing things like "Remove {{ playerName }} from team?" And a few times I mistyped the braces, which caused the whole translation file to fail to load.