首页 > Web开发 > 详细

WP runtime post 请求, json 解析

时间:2015-06-04 15:39:09      阅读:195      评论:0      收藏:0      [点我收藏+]

https://monkeyweekend.wordpress.com/2014/10/23/how-to-send-text-json-or-files-using-httpclient-postasync/

using Windows.Web.Http;

using Windows.Data.Json;

//post request

Windows.Web.Http.HttpClient oHttpClient = new Windows.Web.Http.HttpClient();

Uri uri = new Uri("https://www.abc.com/testapi");
string contentBody = "the data you want to post";

HttpRequestMessage mSent = new HttpRequestMessage(HttpMethod.Post, uri);
mSent.Content =new HttpStringContent(String.Format("{0}", contentBody), Windows.Storage.Streams.UnicodeEncoding.Utf8);

HttpResponseMessage mReceived = await oHttpClient.SendRequestAsync(mSent, HttpCompletionOption.ResponseContentRead);

 

//read reponse to json string

string jsonStr = await mReceived.Content.ReadAsStringAsync();

//parse json

JsonValue jsonValue = JsonValue.Parse(jsonStr);

string bruid = jsonValue.GetObject().GetNamedString("someKey");

WP runtime post 请求, json 解析

原文:http://www.cnblogs.com/yibinpan/p/4551677.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!