❔ Dezerialise JSON response
Example:
person
{
18370101 (changing social security number)
{
name: name, age: age description: "<p> This is a person with name and age </p>" } }
I want to dezerialise the json response into <Person> but the social security number dosent belong to a json property. From what i understand you can use something called Jtoken to solve this but it dosent feel quite right. Are there any alternatives? Also the field description contains html-elements, when im trying to dezerialise it throws an error, one again - any ideas? 🙂 Thanks in advance!
name: name, age: age description: "<p> This is a person with name and age </p>" } }
I want to dezerialise the json response into <Person> but the social security number dosent belong to a json property. From what i understand you can use something called Jtoken to solve this but it dosent feel quite right. Are there any alternatives? Also the field description contains html-elements, when im trying to dezerialise it throws an error, one again - any ideas? 🙂 Thanks in advance!
7 Replies
the example you typed isn't a valid json
Are you creating the JSON manually, or is it provided by some API?
Just like mentioned by Anton, it is invalid json
$jsongen
Instantly parse JSON in any language | quicktype
Whether you're using C#, Swift, TypeScript, Go, C++ or other languages, quicktype generates models and helper code for quickly and safely reading JSON in your apps. Customize online with advanced options, or download a command-line tool.
Convert JSON to C# Classes Online - Json2CSharp Toolkit
Convert any JSON object to C# classes online. Json2CSharp is a free toolkit that will help you generate C# classes on the fly.
I just created the JSON above as an example but in relity it do come from an API. When creating the Perosn class i used "paste as JSON" in visual studio 🙂
it would help if you provide an actually valid json though
leaving out properties during deserialization should not be a problem
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.