如何在此格式化的 JSON 子中使用 RESTSHARP 发送参数 JSON
how do use RESTSHARP send parameter JSON in this formatted JSON sub
我使用 c# 并在方法中使用 Restsharp request.AddBody() 我想要这种格式
{
"boss":[{
"cus":"454",
"date":"July 23,2015",
"mangpo":"9.1",
"namo":"rattatrayaya"
}]
}
但是我的代码:
request.AddBody( new {
boss = new []{"cus":"454","date":"July23,2015","mangpo":"9.1","namo":"rattatrayaya"} });
out put json to sent wrong not have "[":
"boss":{
"cus":"454",
"date":"July 23,2015",
"mangpo":"9.1",
"namo":"rattatrayaya"
}
如何以这种格式在 restsharp 中发送。现在帮帮我!
request.AddBody(new
{
boss = new []
{
new { cus="454", date="July23,2015", mangpo="9.1", namo="rattatrayaya"}
}
});
或者你可以post像这样直接json对象...
request.AddParameter("application/json; charset=utf-8",
"{\"boss\":[{\"cus\":\"454\",\"date\":\"July23,2015\",\"mangpo\":\"9.1\",\"namo\":\"rattatrayaya\"}]}",
ParameterType.RequestBody);
我使用 c# 并在方法中使用 Restsharp request.AddBody() 我想要这种格式
{
"boss":[{
"cus":"454",
"date":"July 23,2015",
"mangpo":"9.1",
"namo":"rattatrayaya"
}]
}
但是我的代码:
request.AddBody( new {
boss = new []{"cus":"454","date":"July23,2015","mangpo":"9.1","namo":"rattatrayaya"} });
out put json to sent wrong not have "[":
"boss":{
"cus":"454",
"date":"July 23,2015",
"mangpo":"9.1",
"namo":"rattatrayaya"
}
如何以这种格式在 restsharp 中发送。现在帮帮我!
request.AddBody(new
{
boss = new []
{
new { cus="454", date="July23,2015", mangpo="9.1", namo="rattatrayaya"}
}
});
或者你可以post像这样直接json对象...
request.AddParameter("application/json; charset=utf-8",
"{\"boss\":[{\"cus\":\"454\",\"date\":\"July23,2015\",\"mangpo\":\"9.1\",\"namo\":\"rattatrayaya\"}]}",
ParameterType.RequestBody);