public object Deserialize(string contentType, Stream bodyStream, BindingContext context) { var deserializedObject = JsonSerializer.DeserializeFromStream(context.DestinationType, bodyStream); if (context.DestinationType.GetProperties(BindingFlags.Public | BindingFlags.Instance).Except(context.ValidModelProperties).Any()) { return(CreateObjectWithBlacklistExcluded(context, deserializedObject)); } return(deserializedObject); }
public void Serialize <TModel>(string contentType, TModel model, Stream outputStream) { JsonSerializer.SerializeToStream(model, outputStream); }
public override Task WriteToStreamAsync(Type type, object value, Stream writeStream, System.Net.Http.HttpContent content, TransportContext transportContext) { var task = Task.Factory.StartNew(() => JsonSerializer.SerializeToStream(value, type, writeStream)); return(task); }
public override Task <object> ReadFromStreamAsync(Type type, Stream readStream, System.Net.Http.HttpContent content, IFormatterLogger formatterLogger) { var task = Task <object> .Factory.StartNew(() => JsonSerializer.DeserializeFromStream(type, readStream)); return(task); }
public string Json_DifferenetSerialize() { return(JsonSerializer.SerializeToString(jsonRoot)); }
/// <summary> /// Get JSON string value converted to T /// </summary> public static T Get <T>(this Dictionary <string, string> map, string key, T defaultValue = default(T)) { string strVal; return(map.TryGetValue(key, out strVal) ? JsonSerializer.DeserializeFromString <T>(strVal) : defaultValue); }