【发布时间】:2018-07-22 19:02:52
【问题描述】:
我想使用 newtonsoft json 序列化器来创建 json。 我在构建 LIST 和集合方面完全是新手,所以我会向你寻求帮助。 创建一个简单的 json 就可以了。 我必须建立一个属性列表,带有一个属性列表。
也许还有其他库,让这更容易?
我需要这个 json:
{
"objectTypeId": 545,
"attributes": [{
"objectTypeAttributeId": 222,
"objectAttributeValues": [{
"value": "Kommentar"
}]
}]
}
所以我开始了
public class Controller
{
public int objectTypeId { get; set; }
public IList<string> attributes { get; set; }
}
Controller controllerjson = new Controller
{
objectTypeId = 545,
// How to add the attributes with each values ?
}
【问题讨论】:
标签: c# json serialization json.net