public CollectionJsonContent(Collection collection) { var serializerSettings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, Formatting = Newtonsoft.Json.Formatting.Indented, ContractResolver = new CamelCasePropertyNamesContractResolver() }; collection.Version = "1.0"; Headers.ContentType = new MediaTypeHeaderValue("application/vnd.collection+json"); using (var writer = new JsonTextWriter(new StreamWriter(_memoryStream)) { CloseOutput = false }) { var readDocument = new ReadDocument { Collection = collection }; var serializer = JsonSerializer.Create(serializerSettings); serializer.Serialize(writer, readDocument); writer.Flush(); } _memoryStream.Position = 0; }
public CollectionJsonContent(Collection collection) { _serializer = JsonSerializer.Create(new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, Formatting = Formatting.Indented, ContractResolver = new CamelCasePropertyNamesContractResolver() }); collection.Version = "1.0"; _readDocument = new ReadDocument(collection); Headers.ContentType = new MediaTypeHeaderValue("application/vnd.collection+json"); }