C# JSON的JavaScriptSerializer
只需要一些帮助就可以发送一篇C#的帖子,该帖子的数据与下面的内容相同C# JSON的JavaScriptSerializer,c#,json,C#,Json,只需要一些帮助就可以发送一篇C#的帖子,该帖子的数据与下面的内容相同 curl -v -u {email_address}:{password} https://{subdomain}.zendesk.com/api/v2/users.json \ -H "Content-Type: application/json" -X POST -d '{"user": {"name": "Roger Wilco", "email": "roge@example.org"}}' 我有下面的基本资料只是需
curl -v -u {email_address}:{password} https://{subdomain}.zendesk.com/api/v2/users.json \
-H "Content-Type: application/json" -X POST -d '{"user": {"name": "Roger Wilco", "email": "roge@example.org"}}'
我有下面的基本资料只是需要改变一点不知道如何。。。问题是我不知道如何创建{“user”:{“name”:“Roger Wilco”,“email”:roge@example.org“}}
最简单的方法可能是使用
user
属性序列化匿名类型:
string json = new JavaScriptSerializer().Serialize(new { user = user });
// {"user":{"name":"Roger Wilco","email":"roger@example.org"}}
如何发送此部分curl-v-u{email_address}:{password}
string json = new JavaScriptSerializer().Serialize(new { user = user });
// {"user":{"name":"Roger Wilco","email":"roger@example.org"}}