public T[] Deserialize(ref JsonReader <TSymbol> reader) { T[] temp = null; T[] result; try { temp = ArrayPool <T> .Shared.Rent(4); reader.ReadBeginArrayOrThrow(); var count = 0; while (!reader.TryReadIsEndArrayOrValueSeparator(ref count)) // count is already preincremented, as it counts the separators { if (count == temp.Length) { FormatterUtils.GrowArray(ref temp); } temp[count - 1] = ElementFormatter.Deserialize(ref reader); } result = count == 0 ? Array.Empty <T>() : FormatterUtils.CopyArray(temp, count); } finally { if (temp != null) { ArrayPool <T> .Shared.Return(temp); } } return(result); }
public QueryContainer Deserialize(ref JsonReader reader, IJsonFormatterResolver formatterResolver) { switch (reader.GetCurrentJsonToken()) { case JsonToken.BeginObject: return(QueryFormatter.Deserialize(ref reader, formatterResolver)); case JsonToken.String: var jsonString = reader.ReadStringSegmentUnsafe(); var jsonStringReader = new JsonReader(jsonString.Array, jsonString.Offset); return(QueryFormatter.Deserialize(ref jsonStringReader, formatterResolver)); default: reader.ReadNextBlock(); return(null); } }
public FSharpValueOption <T> Deserialize(ref JsonReader <TSymbol> reader) { if (reader.ReadIsNull()) { return(FSharpValueOption <T> .ValueNone); } return(FSharpValueOption <T> .NewValueSome(valueFormatter.Deserialize(ref reader))); }
public FSharpOption <T> Deserialize(ref JsonReader <TSymbol> reader) { if (reader.ReadIsNull()) { return(null); } return(FSharpOption <T> .Some(elementFormatter.Deserialize(ref reader))); }
public T?Deserialize(ref JsonReader <TSymbol> reader) { if (reader.ReadIsNull()) { return(null); } return(ElementFormatter.Deserialize(ref reader)); }
public IProperty Read(ref JsonReader reader) { T value = jsonFormatter.Deserialize(ref reader, jsonFormatterResolver); return(new Property <T>(this) { Value = value }); }
private Option <object> ReadRecord(ref JsonReader reader) { reader.SkipWhiteSpace(); if (reader.GetCurrentOffsetUnsafe() >= reader.GetBufferUnsafe().Length) { return(new None()); } return(Formatter.Deserialize(ref reader, StandardResolver.Default)); }
public T?Deserialize(ref JsonReader reader, IJsonFormatterResolver formatterResolver) { if (reader.ReadIsNull()) { return(null); } else { return(underlyingFormatter.Deserialize(ref reader, formatterResolver)); } }
public override T Deserialize <T>(byte[] data) { if (data == null) { throw new ArgumentNullException(nameof(data)); } var reader = new JsonReader(data); IJsonFormatter <T> formatter = Resolver.GetFormatter <T>(); return(formatter.Deserialize(ref reader, Resolver)); }
static TKey ReadIntegerKey(ref JsonReader <TSymbol> reader) { var separator = JsonUtf16Constant.NameSeparator; var doubleQuote = JsonUtf16Constant.DoubleQuote; reader.ReadSymbolOrThrow(Unsafe.As <char, TSymbol>(ref doubleQuote)); var key = KeyFormatter.Deserialize(ref reader); reader.ReadSymbolOrThrow(Unsafe.As <char, TSymbol>(ref doubleQuote)); reader.ReadSymbolOrThrow(Unsafe.As <char, TSymbol>(ref separator)); return(key); }
public override T Deserialize <T>(string data) { if (data == null) { throw new ArgumentNullException(nameof(data)); } byte[] bytes = Encoding.UTF8.GetBytes(data); var reader = new JsonReader(bytes); IJsonFormatter <T> formatter = Resolver.GetFormatter <T>(); return(formatter.Deserialize(ref reader, Resolver)); }
public TList Deserialize(ref JsonReader <TSymbol> reader) { if (reader.ReadIsNull()) { return(null); } reader.ReadBeginArrayOrThrow(); var list = CreateFunctor(); var count = 0; while (!reader.TryReadIsEndArrayOrValueSeparator(ref count)) { list.Add(ElementFormatter.Deserialize(ref reader)); } return(list); }
public TDictionary Deserialize(ref JsonReader <TSymbol> reader) { if (reader.ReadIsNull()) { return(null); } reader.ReadBeginObjectOrThrow(); var result = new Dictionary <string, T>(); var count = 0; while (!reader.TryReadIsEndObjectOrValueSeparator(ref count)) { var key = reader.ReadEscapedName(); var value = ElementFormatter.Deserialize(ref reader); result[key] = value; } return(Converter(result)); }
public TDictionary Deserialize(ref JsonReader <TSymbol> reader) { if (reader.ReadIsNull()) { return(null); } reader.ReadBeginObjectOrThrow(); var result = CreateFunctor(); // using new T() is 5-10 times slower var count = 0; while (!reader.TryReadIsEndObjectOrValueSeparator(ref count)) { var key = reader.ReadEscapedName(); var value = ElementFormatter.Deserialize(ref reader); result[key] = value; } return(result); }
public FSharpMap <string, T> Deserialize(ref JsonReader <TSymbol> reader) { return(new FSharpMap <string, T>(innerFormatter.Deserialize(ref reader))); }
public FSharpList <T> Deserialize(ref JsonReader <TSymbol> reader) { return(ListModule.OfArray(innerFormatter.Deserialize(ref reader))); }
public T Deserialize(ref JsonReader reader, IJsonFormatterResolver formatterResolver) { var obj = formatter.Deserialize(ref reader, formatterResolver); return((T)obj); }