Does C# have a library for parsing multi-level cascading JSON?

后端 未结 2 1787
無奈伤痛
無奈伤痛 2020-12-19 02:02

Is there a library (C# preferred) to resolve what I would call multi-level cascading JSON?

Here is an example of what I mean: (Pseudocode/C#)

<
2条回答
  •  执念已碎
    2020-12-19 02:29

    Not that I know of. For the simple case, you can use any JSON library, then merge the dictionaries with a solution like this one. E.g. using Newtonsoft/Json.NET:

    Dictionary dict1, dict2, dict3, merged;
    dict1 = JsonConvert.DeserializeObject>(json1);
    dict2 = JsonConvert.DeserializeObject>(json2);
    dict3 = JsonConvert.DeserializeObject>(json3);
    merged = Merge(new[]{dict1, dict2, dict3});
    

    Obviously, in production code you'd factor out the redundant lines.

提交回复
热议问题