【发布时间】:2020-07-03 13:10:19
【问题描述】:
我正在编写一个 Web API,其中需要将结果类属性值作为 Json 数组传递以响应 GET 请求。 属性类将作为带有对象的 Ok Status 的实际结果传递。 (我在嘲笑实际需求)
public class ABC
{
public string Name {get;set;}
public string Address{get;set;}
}
我正在关注 dotnet core web api 中提供的默认 JSONfor matter 选项,它将所有类属性转换为单个 json 元素。
{
"Person" :
[
{
"Name": "ABCD",
"Address": "INDIA"
}
]
}
我的要求是 Json 格式的数据,数组如下 -
{
"Person" :
[
{"Name": "ABCD"},
{"Address": "INDIA"}
]
}
【问题讨论】:
标签: c# .net-core asp.net-core-webapi webapi