Answer the question
In order to leave comments, you need to log in
Is there a C# library that allows you to deserialize the string table.Snap[0].HolidayEnable=false?
Is there a C# library that allows you to deserialize the string table.Snap[0].HolidayEnable=false into an object
class Table
{
public Snap[] Snaps {get; set;}
}
class Snap
{
public bool HolidayEnable {get; set;}
}
Answer the question
In order to leave comments, you need to log in
What you want is generally possible, provided that you are ready to connect Roslyn (C # compiler) to your program - it can compile and execute an arbitrary expression on the fly (at the same time, you can input arbitrary data from your program (the same Table ) as "global variables" for the executable expression). Here's an example: https://stackoverflow.com/questions/46524379/creat...
On the other hand, this sort of thing isn't usually used in production code - if you write what you need to do "at the business level", maybe someone can recommend a better solution.
Usually in programming languages there is an eval function or something like that.
It allows you to execute a string as code.
And any documentation on it starts with the words "Never use this function" ;)
In addition to the fact that there are a bunch of serializers that, of course, will not give a line, you can make your own Something like
Static Table Desirialize( string file)
table.Snap[0].HolidayEnable=false
What the method does reads all the lines
Looks at what's in the brackets
Creates an array of snaps
Then runs through parses the value on this line of yours and writes it to the object.
But! This is a perversion. Rewrite your code to a normal serializer and everything will be solved with one line of code
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question