This question is a continuation of this.., rather than changing it, I'm asking a new one here.. My required json format is
{
"nodes": {
"1": {
"2": {
"attriba": "a2",
"label": "2",
"attribc": false
},
"3": {
"attriba": "a3",
"label": "3",
"attribc": false
}
},
"6": {
"4": {
"attriba": "none",
"label": "4",
"attribc": false
},
"5": {
"attriba": "none",
"label": "5",
"attribc": false
}
}
}
}
Now normally I would create classes and fill them with data and call "Newtonsoft.Json.JsonConvert.SerializeObject" to get the desired json string.
But in this case the format is such that I'm unable to figure out the class structure..
The top class as per my last question would be like the following..
public class Response
{
[JsonProperty("nodes")]
public Dictionary<string, Node> Nodes { get; set; }
}
The bottom class ..
public class Nodedata
{
[JsonProperty("attriba")]
public string Attriba { get; set; }
[JsonProperty("attribb")]
public string Attribb { get; set; }
[JsonProperty("label")]
public string Label { get; set; }
[JsonProperty("attribc")]
public bool Attribc { get; set; }
}
But, how do i manage the node class( values "1" & "6") which has again no key value and has a list of Nodedata objects..
Any help will be sincerely appreciated..
Thanks