Showing posts from December, 2017

Serialize EntityFramework Object and Remove Null properties

In the following code, I'm providing a way to serialize an entity object from the EntityFramework taking into consideration the relationships with other entities. I'm providing a way to remove the empty properties, null values and empty arrays from the Json string. First of all, it is important to mention that the following code is applicable only for Newtonsoft API, I'm using JsonConvert.SerializeObject for serialization. Make sure to add a reference to the Newtonsoft.Json.dll. Serialize…

Sort Properties in JSON Object using Newtonsoft.Json

T his post is applicable if you are using Newtonsoft.Json for serialization/deserialization. In this article, I'm sharing C# code to sort the properties in the JSON Object. The order of properties in a JSON  object  is undefined, so the properties are listed in the order they were added to the object Sample JSON String String jsonString = @"{""Email"":""john@mail.com"",""Website"":""http://samplewebsite.com"",""Name…

Load More
That is All