private void _Value(Utf8String key, bool isKey) { CommaCheck(isKey); if (isKey) { Indent(); } JsonString.Quote(key, m_w); }
public void QuoteTest() { { var value = Utf8String.From("ho5日本語ge"); var quoted = Utf8String.From("\"ho5日本語ge\""); Assert.AreEqual(quoted, JsonString.Quote(value)); Assert.AreEqual(value, JsonString.Unquote(quoted)); } { var value = Utf8String.From("fuga\n ho5日本語ge"); var quoted = Utf8String.From("\"fuga\\n ho5日本語ge\""); Assert.AreEqual(quoted, JsonString.Quote(value)); Assert.AreEqual(value, JsonString.Unquote(quoted)); } }
public void StringTest() { { var value = "hoge"; var quoted = "\"hoge\""; Assert.AreEqual(quoted, JsonString.Quote(value)); var node = JsonParser.Parse(quoted); Assert.AreEqual(0, node.Value.Bytes.Offset); Assert.AreEqual(quoted.Length, node.Value.Bytes.Count); Assert.True(node.IsString()); Assert.AreEqual("hoge", node.GetString()); } { var value = "fuga\n hoge"; var quoted = "\"fuga\\n hoge\""; Assert.AreEqual(quoted, JsonString.Quote(value)); var node = JsonParser.Parse(quoted); Assert.AreEqual(0, node.Value.Bytes.Offset); Assert.AreEqual(quoted.Length, node.Value.Bytes.Count); Assert.True(node.IsString()); Assert.AreEqual(value, node.GetString()); } }
public JsonValue Key(Utf8String key, int parentIndex) { return(new JsonValue(JsonString.Quote(key), ValueNodeType.String, parentIndex)); }