Kinda new to working with JSON. How to convert the following:
{
"UserRptDef": {
"ReportDefinitionId": 3002,
"Params": {
"UserParameters": [
{
"Id": "reportid",
"Value": "3002"
}
]
},
"SchedOpt": {
"Frequency": "monthly",
"ExpirationDate": "2015-10-13"
},
"DeliveryOpt": {
"DeliveryType": "email",
"EmailSubject": "JournalReport5 Report",
"EmailRecipients": [
"success+test1@simulator.amazonses.com"
]
}
}
}
To:
UserRptDef, ReportDefinitionId
UserRptDef, Params
UserRptDef, Params, UserParameters
UserRptDef, SchedOpt
UserRptDef, SchedOpt, Frequency
UserRptDef, SchedOpt, ExpirationDate
UserRptDef, DeliveryOpt
UserRptDef, DeliveryOpt, DeliveryType
UserRptDef, DeliveryOpt, EmailSubject
UserRptDef, DeliveryOpt, EmailRecipients
That is, flatten out the hierarchy and only list the Object and Field names without including the values or arrays.
I have this so far, but I feel it's the wrong direction:
var json = File.ReadAllText("json.json");
var js = (JObject)JsonConvert.DeserializeObject(json);
foreach (var p in js.Properties())
{
var xxx = p.Value.AsJEnumerable().Select(t=>t).Select(j=>j);
//not sure where to go from here
}
Thanks for any pointers and or help.
Aucun commentaire:
Enregistrer un commentaire