使用c#打印Json对象



我想返回这个json响应

{
"Type": "testing",
"Errors": {
"InputOne": [
"The input one is accepted"
],
"InputTwo": [
"The input two is accepted"
]
}
}

但试了几轮之后,我得到的是这个

{
"Type": "testing",
"Errors": {
"InputOne": "The input one is accepted",
"InputTwo": "The input two is accepted"
}
}

我可以知道我在这里错过了什么吗?

这些是我的代码

public string Type { get; set; }
public ErrorClass Errors { get; set; }
public class ErrorClass
{
public object InputOne { get; set; }
public object InputTwo { get; set; }
}

提前感谢!

试试这个:

public string Type { get; set; }
public ErrorClass Errors { get; set; }
public class ErrorClass
{
public string[] InputOne { get; set; }
public string[] InputTwo { get; set; }
}

试试这个:你需要返回一个列表/集合/数组InputOneInputTwo根据你的回复。

public string Type { get; set; }
public ErrorClass Errors { get; set; }
public class ErrorClass
{
public List<object> InputOne { get; set; }
public List<object> InputTwo { get; set; }
}

最新更新