U
U
UncleAlexKun2015-10-01 10:17:05
.NET
UncleAlexKun, 2015-10-01 10:17:05

How to create a dynamic class from deserialized XML or JSON in C#?

Is it possible to create a dynamic class in C# by deserialized string:
JSON
{"K":10,"Sums":[12.0,45678.0,12.0,512.0],"Muls":[3,5,10,12,45]}
XML
pastebin.com/MuSHLSH0

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya, 2015-10-01
@UncleAlexKun

I will answer for JSON. If I understand everything correctly, then I do it using Json.NET in this way:
For XML, here is stackoverflow.com/questions/13171525/converting-xm... and here: stackoverflow.com/questions/13704752/deserialize-x...

D
Dmitry Kovalsky, 2015-10-01
@dmitryKovalskiy

If only an object of an anonymous class. Do you have generic XML/JSON format or random/unknown? If typical, then you can make your own class and describe serialization / deserialization.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question