我需要使用json请求与fiddler一起测试终结点。我知道您可以通过将其添加到请求正文中来发送自定义对象。
{
"Name" : "testing//moretest//tiredd",
"Description": "this is a test.",
}
但是此对象具有一个自定义的“ Metadata”对象,我也想填充该对象...
public class MetadataModel
{
public int Identifier { get; set; }
public string Path { get; set; }
}
所以很明显,我尝试按如下所述制作请求正文,但无济于事...有帮助吗?
{
"Name" : "testing//moretest//tiredd",
"Description": "this is a test.",
"Metadata" : {"Identifier" : "2", "Path" : "Test"}
}
我也尝试过将大括号括在引号中...没有运气。
如果我省略了“元数据”行,则将填充该对象,而Metadata对象为null。当我包含它时,整个对象为null
{
"Name" : "testing//moretest//tiredd",
"Description": "this is a test.",
"Metadata" : {"Identifier" : 2, "Path" : "Test"}
}
假设Ralph WIllgoss的答案不能解决问题(并且可能以前我错过了它),您可能只需要删除2中的引号-不应引用JSON整数,因此它不会选择该引号正确地上升。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句