【问题标题】:How to parse string and array JSON data in Android [closed]如何在 Android 中解析字符串和数组 JSON 数据 [关闭]
【发布时间】:2015-06-25 22:52:36
【问题描述】:

我需要解析以下 JSON 文本以获取我的 Android 应用程序标题(主标题)和标题(子标题)、描述、imageHref。

{
  "title":"Flowers",
  "rows":[
     {
        "title":"Azalea",
        "description":"Beautiful large royal purple flowers adorn attractive satiny green leaves that turn orange/red in cold weather. Grows to up to 18 feet, or prune annually to shorten.",
        "imageHref":"http://...../../b/california_snow.jpg"
     },
     {
        "title":"Tibouchina",
        "description":"Blooms in summer, 20-35 inches high. Fertilize regularly for best results. Full sun, drought tolerant.",
        "imageHref":"http://...../../b/california_snow.jpg"
     }
}

请帮我获取所需的代码。我正在使用 JSONparser。

【问题讨论】:

  • 我们不是来帮你做家务的。

标签: java android json


【解决方案1】:

尝试使用

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

GsonBuilder gsonBuilder = new GsonBuilder();
Gson gson=gsonBuilder.create();
gson.fromJson(<return type>,<expected type>);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-23
    • 1970-01-01
    • 2013-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-06
    • 1970-01-01
    相关资源
    最近更新 更多