【发布时间】:2015-06-22 19:45:24
【问题描述】:
我不想只发布 JSON,而是想将 JSON array 发布到发布请求的一个参数。
代码:
var locations = new Dictionary<string, object>();
locations.Add("A", 1);
locations.Add("B", 2);
locations.Add("C", 3);
request.AddObject(locations);
request.AddParameter("date", 1434986731000);
AddObject 失败,因为我认为新的 RestSharp JSON 序列化程序无法处理字典。 (此处错误:http://pastebin.com/PC8KurrW)
我也试过request.AddParameter("locations", locations);
但这根本不会序列化为 json。
我希望请求看起来像
locations=[{A:1, B:2, C:3}]&date=1434986731000
[] 很重要,即使它只有 1 个 JSON 对象。它是一个 JSON 对象数组。
【问题讨论】:
标签: c# json serialization restsharp