How to Deserialize JSON data?

You can deserialize this really easily. The data’s structure in C# is just List<string[]> so you could just do; List<string[]> data = JsonConvert.DeserializeObject<List<string[]>>(jsonString); The above code is assuming you’re using json.NET. EDIT: Note the json is technically an array of string arrays. I prefer to use List<string[]> for my own declaration because it’s imo more … Read more

Json.NET deserialize or serialize json string and map properties to different property names defined at runtime

You could use a custom ContractResolver to do this. Basically it is the same idea as putting a [JsonProperty] attribute on each class member for which you want to map to a different JSON property name, except you do it programmatically via the resolver. You can pass a dictionary of your desired mappings to the … Read more

Deserializing JSON when sometimes array and sometimes object

A very detailed explanation on how to handle this case is available at “Using a Custom JsonConverter to fix bad JSON results”. To summarize, you can extend the default JSON.NET converter doing Annotate the property with the issue [JsonConverter(typeof(SingleValueArrayConverter<OrderItem>))] public List<OrderItem> items; Extend the converter to return a list of your desired type even for … Read more

How To Deserialize Dynamic dirty json data in node js posted by react [duplicate]

Below shows you one approach to consider. The key is the use of the StudentDetails class to define the necessary properties of your individual students (as well as the Dictionary – so that it is keyed by the string (e.g. “John”)). using System; using System.Collections.Generic; using Newtonsoft.Json; namespace Sample { public class StudentDetails { public … Read more