NewtonSoft JSON - How to deserialize JSON file with no root object? It's been ages since I last touched C#, so I'm very rusty. But the answer shouldn't be hard at all for anyone that has done JSON work. Message:Cannot deserialize JSON object into type System.Collections.Generic.List`1ConsoleApplication2.Employee. The deserialized type should be a normal.NET type (i.e. Not a primitive type like integer, not a collection type like an array or List or a dictionary type (. Dictionary TKey, TValue. JSON deserialization with JSON.net: class hierarchies In part 1 of this series I described the basics of creating classes from a JSON string and then simply deserializing the string into a (list of) classes.
Archived
I have the following class setup
There are actually about 7 inheriting classes in the actual implementation, but you get the idea.
My application has to both save data to a JSON
As well as be able to retrieve data from that JSON file and reconstitute it as a an object. Nintendo emulator games.
The issue I'm running into is, while JSON.NET will serialize the List object, even going so far as to include the concrete class types, when I pull the JSON back in, the List object is null. What am I missing?
Newtonsoft Json Deserialize Abstract Class
7 comments
Posted by4 months ago
It's been ages since I last touched C#, so I'm very rusty. But the answer shouldn't be hard at all for anyone that has done JSON work.
The program I'm making, will allow the user to replace the values in the IngredientID, IngrediantQuanity, ResultID, and ResultQuantity fields with different ones en masse. Simply select an ID to find, an ID to replace it with, and it will automate the whole process.
Newtonsoft Json Deserialize Enum
But, I've hit a snag. There's no named root object for the JSON data, so I don't know to proceed. Any advice?
Newtonsoft Json Deserialize Null
Here's the code that deals directly with the JSON file: https://pastebin.com/V9DBQvDM