public object ReadJson(ref JReader reader) { var value = reader.Any(); switch (value.Type) { case ValueType.Bool: return(value.BoolValue); case ValueType.Number: return(value.NumberValue); case ValueType.String: return(value.StringValue); case ValueType.Array: var list = new List <object>(); for (var arr = value.ArrayValue; arr.Next(ref reader);) { list.Add(ReadJson(ref reader)); } return(list); case ValueType.Object: var dict = new Dictionary <string, object>(); for (var obj = value.ObjectValue; obj.Next(ref reader);) { dict[obj.Name.ToString()] = ReadJson(ref reader); } return(dict); default: return(null); } }
private void ReadAnyValue(ref JReader r, TestValue <ReaderAction> value) { var av = r.Any(); Assert.Equal(value.Type, av.Type); switch (value.Type) { case ValueType.Bool: Assert.Equal(value.BoolValue, av.BoolValue); break; case ValueType.Number: Assert.Equal(value.NumberValue, av.NumberValue); break; case ValueType.String: Assert.Equal(value.StringValue, av.StringValue.ToString()); break; case ValueType.Array: ReadArray(ref r, av.ArrayValue, value); break; case ValueType.Object: ReadObject(ref r, av.ObjectValue, value); break; default: break; } }