Json array with multiple types to object
Hi,
I've got the following JSON Array of an array (that I can't change)
How would I go about deserializing this using system.text.json?
I'm fine with a solution that gives me a class (with a string and int as properties) or with casting the int to a string somehow and thus having an
string[][]
4 Replies
Wouldn't
object[][]
work...?I was hoping for something more elegant 😛
Otherwise depending on how much effort you're willing to put in, you could maybe create a type which represents either an integer or a string, then write a custom JSON converter for it.
Hmm,
object[][]
makes it a JsonElement
and not a string/int 🤔
Figured it out with a custom converter after all
Thanks