❔ Am trying to convert this json into a data object.

I have a data object which has matching properties to what's contained in the JSON. As can be seen in the image the JSON file is being pulled through correctly. I am hoping for my list 'b' to be list of my data object. Would be very grateful for any help.
12 Replies
sexysexysamthorpe
Here are the variables I have declared on the bodies class
Angius
Angius2y ago
You need properties JSON serializer doesn't work with fields
Angius
Angius2y ago
Especially since they're private
Saber
Saber2y ago
consider pasting the json into a tool which creates the classes for you, you need a root object that contains the bodies property you can't deserialize it directly to a list
Angius
Angius2y ago
$jsongen
MODiX
MODiX2y ago
Use https://app.quicktype.io or https://json2csharp.com to generate classes from your JSON
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.
Angius
Angius2y ago
Or Edit -> Paste Special -> JSON As Classes
sexysexysamthorpe
I love you guys thanks
sexysexysamthorpe
So would something like this do the trick?
sexysexysamthorpe
It worked 🙂
Accord
Accord2y ago
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.
Want results from more Discord servers?
Add your server