Simple json causes exception "ArgumentOutOfRangeException: Length cannot be less than zero.":
@@ -940,11 +940,13 @@ namespace Defective.JSON {
}
static void ParseFinalObjectIfNeeded(string inputString, JSONObject container, int startOffset, int lastValidOffset) {
- if (IsClosingCharacter(inputString[lastValidOffset]))
+ // lastValidOffset only advances past non-whitespace characters, so if it still points at
+ // whitespace, nothing but whitespace has been seen since the last comma/colon/opening bracket
+ // and there's no pending value to parse (e.g. an object/array containing only whitespace).
+ if (IsClosingCharacter(inputString[lastValidOffset]) || Array.IndexOf(Whitespace, inputString[lastValidOffset]) > -1)
return;
var child = Create();
Simple json causes exception "ArgumentOutOfRangeException: Length cannot be less than zero.":
Claude suggest following patch: