Can anyone help me with how I should code a c# model to so that I deserialise JSON from a webservice - I thought this would be quick and easy but the JSON is trickier than I expected - when I paste the sample JSON into visual studio and do a paste special > generate class from JSON the resulting class contains objects that are actually the name of the category id's themselves.....can anyone shed any light on how I can structure the model to deserialise the JSON into so that I can get the categories into an IEnumerable of category types ....here is an example of the JSON.....
category — Checkfront API 3.0 documentation
any help gratefully received!

Pasang TamangRank #449 · 5.6K reputationPosted Jan 25, 2023, 10:36 AM EST
Hi,
You can use https://json2csharp.com/ to generate model from your json.Then you can use Newtonsoft.Json to deserialize JSON response into the model. You can check below code example.
public class Root { public string FirstName { get; set; } public string MiddleName { get; set; } }var jsonResponse = ""; var data = JsonConvert.DeserializeObject(jsonResponse);Regards,
Pasang
Rajeesh MenothRank #118 · 18.4K reputationPosted Jan 25, 2023, 8:43 AM EST
Newtonsoft Json you can use for all the Serialization & Deserialization in .Net C#. I am not able to see any Json in your question.
Sachin SinghRank #66 · 26.2K reputationPosted Jan 25, 2023, 12:32 PM EST
Yes, I can understand that you must be getting Classes as 1_, 2_,3_ like these.
You need to format the Response to make it array of category object. Or if there is any forum of checkfront API then you can ask there.