Question

Let's say I've got such a class:

class A
{
    Dictionary<string, string> Dict1 { get; set }
}

And I want it to be serialized to Json like that:

"A" : {"strKey1" : "strVal1", "strKey2" : "strVal2"}

instead of:

"A" : { "Dict1" : {"strKey1" : "strVal1", "strKey2" : "strVal2"}}

so to say, I'd like to skip generating the "Dict1" key.

Is it possible?

Alternatively, how to force serialization of "custom" dictionary members? When I write my class like this:

class A : Dictionary<string, string> 

they key/value pairs of the dictionary do not get serialized...

Thank you in advance!

Was it helpful?

Solution

I got it myself - custom serialization.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top