Given the following JSON samples, what is the best way to parse this in c# .NET?
{"data":{"5":{"isDeleted":"false","day":"THU"}},"action":"edit"}
{"data":{"7":{"isDeleted":"false","name":"alex"}},"action":"edit"}
{"data":{"90":{"isDeleted":"true","job":"software"}},"action":"edit"}
I have looked into JSON serializing into an object but because the data could be different each time i can’t map it directly to a model.
2
Answers
So the model for this could be
You can deserialize the JSON into a
dynamic
object, which allows you to access the properties of the JSON object without having to define a specific model withJsonSerializer
ofSystem.Text.Json
: