我为Android编写应用程序,并有Json解析器
我将其解析为字符串,但我需要将其解析为文件,例如.txt。
我该怎么做呢?
代码:
private async Task<JsonValue> FetchAsync(string url)
{
// Create an HTTP web request using the URL:
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(new Uri(url));
request.ContentType = "application/json";
request.Method = "GET";
// Send the request to the server and wait for the response:
using (WebResponse response = await request.GetResponseAsync())
{
// Get a stream representation of the HTTP web response:
using (Stream stream = response.GetResponseStream())
{
// Use this stream to build a JSON document object:
JsonValue jsonDoc = await Task.Run(() => JsonObject.Load(stream));
//dynamic data = JObject.Parse(jsonDoc[15].ToString);
Console.Out.WriteLine("Response: {0}", jsonDoc.ToString());
// Return the JSON document:
return jsonDoc;我在C#上写应用程序,Xamarin
发布于 2015-10-19 04:50:45
StreamWriter sw = new StreamWriter (filepath);
sw.Write(json);
sw.Close();https://stackoverflow.com/questions/33203068
复制相似问题