我需要AWS SNS正确格式化的JSON对象,但我的格式是错误的。
dynamic foo = new ExpandoObject();
foo.GCM = new ExpandoObject {};
foo.GCM.data = new ExpandoObject();
foo.GCM.data.message = "bogus";
string json = Newtonsoft.Json.JsonConvert.SerializeObject(foo,Newtonsoft.Json.Formatting.None);
结果:{" GCM ":{"数据":{"消息":"虚假"}}}
要求格式:{"GCM":"{"数据":{"消息","虚假"}}"}
dynamic foo = new ExpandoObject();
foo.data = new ExpandoObject();
foo.data.message = "bogus";
string json1 = JsonConvert.SerializeObject(foo, Newtonsoft.Json.Formatting.None);
var json = JsonConvert.SerializeObject(new { GCM=json1 } , Newtonsoft.Json.Formatting.None);
OUTPUT: {"GCM":"{"data":{"message":"bogus"}}"}
但是我不明白为什么这个Required格式需要双重序列化。你确定吗?