码迷,mamicode.com
首页 > Web开发 > 详细

WP runtime post 请求, json 解析

时间:2015-06-04 15:40:52      阅读:142      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!