Tested with VRChat client build [1901].
I would like VRCJson.TryDeserializeFromJson to accept valid JSON containing whitespace before the root object or array.
Reproduction code:
string controlJson = @"{""x"":1}";
string leadingSpaceJson = @" {""x"":1}";
bool controlSuccess =
VRCJson.TryDeserializeFromJson(
controlJson,
out DataToken controlResult);
bool leadingSpaceSuccess =
VRCJson.TryDeserializeFromJson(
leadingSpaceJson,
out DataToken leadingSpaceResult);
Debug.Log("Control: " + controlSuccess);
Debug.Log("Leading space: " + leadingSpaceSuccess);
Debug.Log(leadingSpaceResult.ToString());
Expected output:
Control: True
Leading space: True
Actual output:
Control: True
Leading space: False
UnableToParse: Unable to Deserialize from Json:
Found unexpected type Object while looking for key
Leading whitespace is permitted in JSON. Users can currently work around this
by calling Trim() before deserialization:
VRCJson.TryDeserializeFromJson(json.Trim(), out DataToken result);
However, accepting leading JSON whitespace directly would make the method more compatible with valid JSON returned by external services.