I have the following JSON (not the true data) in the following format, which I am trying to convert into C# equivalent classes. If you noticed that type_1, type_2 these could be in any numbers. which is difficult to put in collection(sort of anonymous). If i remove all type_1, type_2 ... from the JSON it is easy can be converted to classes. Since it in dynamic in nature it is making it difficult.
I have tried http://json2csharp.com/ to get the classes. Problem is, it converts "types" as members, which is not true, it should be a dynamic collection or an array.
This slight different problem
This question has 2 extra problems first "type_1" elements are dynamic and second is these are not in list or an array.
I don't have control over this JSON format which is extra frustration.
{
"type_1": {
"@type": "blob",
"content_type": "image/jpeg",
"digest": "sha1-rCY0Tk8qRqaLfiQXdxYeX9Y+WMI="
},
"type_2": {
"@type": "blob",
"content_type": "image/jpeg",
"digest": "sha1-rCY0Tk8qRqaLfiQXdxYeX9Y+WMI="
},
"type_3": {
"@type": "blob",
"content_type": "image/jpeg",
"digest": "sha1-rCY0Tk8qRqaLfiQXdxYeX9Y+WMI=",
},
"type_4": {
"@type": "blob",
"content_type": "image/jpeg",
"digest": "sha1-rCY0Tk8qRqaLfiQXdxYeX9Y+WMI=",
},
"type_5": {
"@type": "blob",
"content_type": "image/jpeg",
"digest": "sha1-rCY0Tk8qRqaLfiQXdxYeX9Y+WMI=",
},
"References": {
"blob_1": {
"content_type": "image/jpeg",
"digest": "sha1-rCY0Tk8qRqaLfiQXdxYeX9Y+WMI=",
"revpos": 1,
"stub": true
},
"blob_2": {
"content_type": "image/jpeg",
"digest": "sha1-rCY0Tk8qRqaLfiQXdxYeX9Y+WMI=",
"revpos": 1,
"stub": true
}
},
"someproperty1": "somevalue1",
"someproperty2": "somevalue2",
"someproperty3": "somevalue3",
"someproperty4": "somevalue4",
"someproperty5": "somevalue5"
}
I was thinking something like
Filecollection is nothing but that anonymous collection; no luck ;(
public partial class Doc
{
[JsonProperty("references")]
public Dictionary<String, Attachments> Attachments { get; set; }
public List<Dictionary<String, Details>> FileCollections { get; set; }
[JsonProperty("someproperty")]
public String someproperty { get; set; }
[JsonProperty("someproperty2")]
public String someproperty2 { get; set; }
[JsonProperty("someproperty3")]
public String someproperty3 { get; set; }
}