Tag: json
-
Out Of Memory exception when deserializing with JSON.net – Use Streams instead
Calling an api and deserializing the returned json into a type is something I have to do quite often. I used to use the following: //assume client is an instance of HttpClient – this part isn’t important var response = await client.PostAsync(url, content); //read the response as a string var responseString = await response.Content.ReadAsStringAsync(); //use…
-
Removing $id from JSON returned by WebApi
If you’re using the default JSON formatter (ie- haven’t set another one up) your outputted JSON may look something like this: [ { $id: “1”, FirstName: “John”, LastName: “Smith”, }, { $id: “2”, FirstName: “Sarah”, LastName: “Harris”, }, { $id: “3”, FirstName: “Michael”, LastName: “Jones”, }, { $id: “4”, FirstName: “Harry”, LastName: “Green”, } ]…