internal void Write(ReadOnlySpan <char> s) { offset += Quoting.Quote(s, Remaining); }
/// <summary> /// Advance to the next token, throwing a JsonException on a parse error. /// </summary> public bool MoveNext() { if (Current == JsonToken.Eof) { return(false); } begin = end; while (begin < last && char.IsWhiteSpace(buffer[begin])) { begin++; } if (begin == last) { end = begin; Current = JsonToken.Eof; } else { switch (buffer[begin]) { case '{': Current = JsonToken.ObjectStart; end = begin + 1; break; case '}': Current = JsonToken.ObjectEnd; end = begin + 1; break; case '[': Current = JsonToken.ArrayStart; end = begin + 1; break; case ']': Current = JsonToken.ArrayEnd; end = begin + 1; break; case ':': Current = JsonToken.Colon; end = begin + 1; break; case ',': Current = JsonToken.Comma; end = begin + 1; break; case '"': var(qchars, uchars) = Quoting.Unquote(Slice()); Current = JsonToken.String; end = begin + qchars; CurrentSegment = Slice(uchars); return(true); case 't': if (MatchTrue()) { Current = JsonToken.Bool; end = begin + 4; } else { goto default; } break; case 'f': if (MatchFalse()) { Current = JsonToken.Bool; end = begin + 5; } else { goto default; } break; case 'n': if (MatchNull()) { Current = JsonToken.Null; end = begin + 4; } else { goto default; } break; case '-': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': var nchars = MatchNumber(); if (nchars > 0) { Current = JsonToken.Number; end = begin + nchars; } else { goto default; } break; default: throw new JsonException(segment, begin, false, "unexpected character"); } } CurrentSegment = Slice(end - begin); return(true); }