【问题标题】:What C# data type would you de-serialize this Json into你会将这个 Json 反序列化成什么 C# 数据类型
【发布时间】:2022-07-16 22:07:56
【问题描述】:

当 3 字符代码(ara、ces、cym、dei 等)是动态的时,我会将以下 json 反序列化为哪种 C# 数据类型/列表/类。

谢谢!

"translations":{
"ara":{"official":"مملكة هولندا","common":"هولندا"},
"ces":{"official":"Nizozemské království","common":"Nizozemsko"},
"cym":{"official":"Kingdom of the Netherlands","common":"Netherlands"},
"deu":{"official":"Niederlande","common":"Niederlande"},
"est":{"official":"Madalmaade Kuningriik","common":"Holland"}
}"

当我说动态时 - 在运行时您不知道它们是什么或将返回多少。

【问题讨论】:

    标签: c# json deserialization


    【解决方案1】:

    你可以把这个json反序列化成

    具有T(t)ranslations属性的类

    这个属性是Dictionary<string, SomeClass>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-23
      相关资源
      最近更新 更多