private static JsonValue ParseJsonValue(JsonTokenizer tokenizer, JsonToken top) { return(top.Type switch { JsonTokenType.LBrace => (JsonValue)ParseJsonObject(tokenizer, top), JsonTokenType.LBracket => ParseJsonArray(tokenizer, top), JsonTokenType.LiteralTrue => new JsonBool(true), JsonTokenType.LiteralFalse => new JsonBool(false), JsonTokenType.LiteralNull => new JsonNull(), JsonTokenType.String => new JsonString(EscapeSequenceConverter.Decode(top.Value)), JsonTokenType.Number => new JsonNumber(top.Value.ToString()), /* * case JsonTokenType.RBracket: * case JsonTokenType.RBrace: * case JsonTokenType.Colon: * case JsonTokenType.Comma: * case JsonTokenType.NotAToken: * case anything else: */ _ => throw new Exception(), });
public void DecodeBase() { Assert.Equal("\b\r\t\n\0\f\"\\", EscapeSequenceConverter.Decode(@"\b\r\t\n\0\f\""\\")); Assert.Equal("\\\\b\\r\\t\\n\\0\\f\\\"", EscapeSequenceConverter.Decode(@"\\\\b\\r\\t\\n\\0\\f\\""")); }
public void DecodeResume() { Assert.Equal("ara\r\\g\\", EscapeSequenceConverter.Decode(@"ara\r\g\")); Assert.Equal("\\ufool\\u433", EscapeSequenceConverter.Decode(@"\ufool\u433")); }
public void DecodeUnicode() { Assert.Equal("スgokuかわいい", EscapeSequenceConverter.Decode(@"\u30b9gok\u0075かわい\u3044")); }