I have a case where network call will retrieve json string. And it is like
"{"PdfSearchCTTestExperiment": 0, "_ecs": {"PdfSearchCTTestExperiment": "P-X-100967-1-13"}}"
Basically, the response will have two value types, one is string and another one is dictionary<string, string>.
And I need to deserilize both inner and outer key value pairs into dictionary. Here is my way of doing it:
var outerDict = JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(ss);
string innerDictString = JsonConvert.SerializeObject(outerDict["_ecs"]);
var innerDict = JsonConvert.DeserializeObject<Dictionary<string, string>>(innerDictString );
It works, but I do not feel it is the efficient way. Baiscally, because of the type system, I need to do like two more times parsing. Any better way to achieve this? Thanks!