示例#1
0
 public JsonPair(string name,
                 char value)
     : this(name)
 {
     if ((char)0 == value)
     {
         Value = new JsonNull();
     }
     else
     {
         Value = new JsonString(XmlConvert.ToString(value));
     }
 }
示例#2
0
 public JsonPair(string name,
                 char value)
     : this(name)
 {
     if ((char)0 == value)
     {
         Value = new JsonNull();
     }
     else
     {
         Value = new JsonString(XmlConvert.ToString(value));
     }
 }
示例#3
0
        public virtual void ReadJson(JsonReader reader)
        {
            if (null == reader)
            {
                throw new ArgumentNullException("reader");
            }

            if (JsonNodeType.Object != reader.NodeType)
            {
                throw new InvalidOperationException();
            }

            if (reader.IsEmptyObject)
            {
                reader.Read();
                return;
            }

            string name = null;

            while (reader.Read())
            {
                JsonValue value = null;
                switch (reader.NodeType)
                {
                case JsonNodeType.Name:
                    name = reader.Name;
                    break;

                case JsonNodeType.NullValue:
                    value = new JsonNull();
                    break;

                case JsonNodeType.TrueValue:
                    value = new JsonTrue();
                    break;

                case JsonNodeType.FalseValue:
                    value = new JsonFalse();
                    break;

                case JsonNodeType.NumberValue:
                    value = new JsonNumber(reader.Value);
                    break;

                case JsonNodeType.StringValue:
                    value = new JsonString(reader.Value);
                    break;

                case JsonNodeType.Array:
                    value = ReadJsonArray(reader);
                    break;

                case JsonNodeType.Object:
                    var obj = new JsonObject();
                    obj.ReadJson(reader);
                    value = obj;
                    break;

                case JsonNodeType.EndObject:
                    return;
                }

                if (null != value)
                {
                    Add(name, value);
                }
            }
        }