I have a requirement that several of my colleagues' configuration files should be displayed uniformly with the PropertyGrid control, which I have implemented with reference to the following post:https://www.codeproject.com/Articles/193462/Using-PropertyGrid-to-Display-and-Edit-Dynamic-Obj.
My way is: define a ConfigObject object first, then deserialized json configuration file into ConfigObject object using JsonConvert.Convert(Newtonsoft.Json), and then assigned to the PropertyGrid.SelectedObject. But this way I can only display and edit the one level of nested json objects, if more than two levels of nested structure, so the nested property field will be not editable.
Consider the following two-level JSON structure:
{
"DAMultiCast": "18:80:c2:00:00:0e",
"SA": "18:60:24:A8:77:FF",
"gPTPType": "0x88f7",
"AVTPType": "0x22f0",
"Initial": {
"SyncMessageType": "0x10",
"FollowupMessageType": "0x18",
"ReqMessageType": "0x12",
"RespMessageType": "0x13",
"RespFollowupMessageType": "0x1A",
"versionPTP": "0x02",
"SyncMessagelength": "44",
"FollowupMessagelength": "76",
"ReqMessagelength": "54",
"subdomainnumber": "0",
"resv0": "0x00",
"Syncflagfield": "0x0208",
"Followupflagfield": "0x0008",
"correctionField": "00:00:00:00:00:00:00:00",
"resv1": "00:00:00:00",
"SyncClockIdentity": "01:02:03:ff:fe:46:76:34",
"RespClockIdentity": "00:22:97:ff:fe:80:0d:f2",
"sourcePortId": "0x0001",
"sequenceId": "143",
"SyncControlField": "0",
"FollowupControlField": "2",
"DelayReqControlField": "5",
"logMessagePeriod": "-3",
"tlvType": "3",
"lengthField": "28",
"organizationId": "32962",
"organizationSubType": "1",
"cumulativeScaledRateOffset": "0",
"gmTimeBaseIndicator": "0",
"lastGmPhaseChange": "00:00:00:00:00:00:00:00:00:00:00:00",
"scaledLastGmFreqChange": "0",
"requestingPortIdentity": "01:02:03:ff:fe:46:76:34",
"requestingPortId": "1"
},
"TM1_TG1_6.1.1B": {
"WaitTime1": "10",
"WaitTime2": "2"
}
}