首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将JSON解析为文件

将JSON解析为文件
EN

Stack Overflow用户
提问于 2015-10-19 04:46:40
回答 1查看 59关注 0票数 0

我为Android编写应用程序,并有Json解析器

我将其解析为字符串,但我需要将其解析为文件,例如.txt。

我该怎么做呢?

代码:

代码语言:javascript
复制
 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

EN

回答 1

Stack Overflow用户

发布于 2015-10-19 04:50:45

代码语言:javascript
复制
StreamWriter sw = new StreamWriter (filepath);
sw.Write(json);
sw.Close();
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33203068

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档