【发布时间】:2021-12-13 20:22:14
【问题描述】:
我有以下课程
public class Customer{
public string name {get;set;}
public JObject properties {get;set;} = new JObject();
}
现在我正在向客户属性添加属性
var customer = new Customer();
customer.properties["wow-123:test"] = new {
name = "Mark,
company = new {
name = "LLC",
address = new {
city= "London" } } }
最后我希望它看起来像:
"properties": {
"wow-123:test": [
{
"name": "Mark",
"company": {
"name": "LLC",
"address ": {
"city": "London"
}
}
}
]
}
我不断收到无法将其转换为 Jtoken 的错误消息。如果我将其更改为 ToString 则它不是 JSON 格式。我怎样才能实现上述目标?
【问题讨论】: