diff --git a/sources/Data/JSON/JArray.uc b/sources/Data/JSON/JArray.uc index 194c8ac..3108913 100644 --- a/sources/Data/JSON/JArray.uc +++ b/sources/Data/JSON/JArray.uc @@ -548,12 +548,12 @@ public function JSON Clone() public function bool ParseIntoSelfWith(Parser parser) { local bool parsingSucceeded; - local Parser.ParserState initState; + local Parser.ParserState initState, confirmedState; local JStorageAtom nextAtom; local array parsedAtoms; if (parser == none) return false; initState = parser.GetCurrentState(); - parser.Skip().Match("[").Confirm(); + confirmedState = parser.Skip().Match("[").GetCurrentState(); if (!parser.Ok()) { parser.RestoreState(initState); @@ -561,18 +561,19 @@ public function bool ParseIntoSelfWith(Parser parser) } while (parser.Ok() && !parser.HasFinished()) { - parser.Skip().Confirm(); + confirmedState = parser.Skip().GetCurrentState(); if (parser.Match("]").Ok()) { parsingSucceeded = true; break; } - if (parsedAtoms.length > 0 && !parser.R().Match(",").Skip().Ok()) { + if ( parsedAtoms.length > 0 + && !parser.RestoreState(confirmedState).Match(",").Skip().Ok()) { break; } - else { - parser.Confirm(); + else if (parser.Ok()) { + confirmedState = parser.GetCurrentState(); } - nextAtom = ParseAtom(parser.R()); + nextAtom = ParseAtom(parser.RestoreState(confirmedState)); if (nextAtom.type == JSON_Undefined) { break; } diff --git a/sources/Data/JSON/JObject.uc b/sources/Data/JSON/JObject.uc index 8b74006..58e2795 100644 --- a/sources/Data/JSON/JObject.uc +++ b/sources/Data/JSON/JObject.uc @@ -537,12 +537,12 @@ public function JSON Clone() public function bool ParseIntoSelfWith(Parser parser) { local bool parsingSucceeded; - local Parser.ParserState initState; + local Parser.ParserState initState, confirmedState; local JProperty nextProperty; local array parsedProperties; if (parser == none) return false; initState = parser.GetCurrentState(); - parser.Skip().Match("{").Confirm(); + confirmedState = parser.Skip().Match("{").GetCurrentState(); if (!parser.Ok()) { parser.RestoreState(initState); @@ -550,19 +550,21 @@ public function bool ParseIntoSelfWith(Parser parser) } while (parser.Ok() && !parser.HasFinished()) { - parser.Skip().Confirm(); + confirmedState = parser.Skip().GetCurrentState(); if (parser.Match("}").Ok()) { parsingSucceeded = true; break; } - if (parsedProperties.length > 0 && !parser.R().Match(",").Skip().Ok()) { + if ( parsedProperties.length > 0 + && !parser.RestoreState(confirmedState).Match(",").Skip().Ok()) { break; } - else { - parser.Confirm(); + else if (parser.Ok()) { + confirmedState = parser.GetCurrentState(); } - parser.R().Skip().MStringLiteral(nextProperty.name).Skip().Match(":"); + parser.RestoreState(confirmedState).Skip(); + parser.MStringLiteral(nextProperty.name).Skip().Match(":"); nextProperty.value = ParseAtom(parser.Skip()); if (!parser.Ok() || nextProperty.value.type == JSON_Undefined) { break;