Exemplo n.º 1
0
 private void _Value(Utf8String key, bool isKey)
 {
     CommaCheck(isKey);
     if (isKey)
     {
         Indent();
     }
     JsonString.Quote(key, m_w);
 }
Exemplo n.º 2
0
        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));
            }
        }
Exemplo n.º 3
0
        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());
            }
        }
Exemplo n.º 4
0
 public JsonValue Key(Utf8String key, int parentIndex)
 {
     return(new JsonValue(JsonString.Quote(key), ValueNodeType.String, parentIndex));
 }