Gson解析JSON数据实例

Gson解析JSON数据实例_第1张图片

{
  "respBody": {
    "timestamp": "1482745098465",
    "enableTingyun": true,
    "recommendIcon": "http://27.151.112.180:8005/xyzqylb2.1/images/icon/20161226173818/FDD683F0001145DAB5.png",
    "splash": [
      {
        "detail": "",
        "title": "ios4",
        "remark": "",
        "imageUrl": "",
        "linkParam": "",
        "link": "http://estock.xyzq.com.cn/fundmatch/views/index.html?channel=ylb",
        "iconUrl": "http://27.151.112.180:8005/xyzqylb2.1/images/splash/default/1CD17D9128A843C5AA.png",
        "linkType": "2"
      },
      {
        "detail": "",
        "title": "ios5",
        "remark": "",
        "imageUrl": "",
        "linkParam": "",
        "link": "http://estock.xyzq.com.cn/fundmatch/views/index.html?channel=ylb",
        "iconUrl": "http://27.151.112.180:8005/xyzqylb2.1/images/splash/default/69E0480E90504364B911111.png",
        "linkType": "2"
      },
      {
        "detail": "",
        "title": "1080p",
        "remark": "",
        "imageUrl": "",
        "linkParam": "",
        "link": "http://estock.xyzq.com.cn/fundmatch/views/index.html?channel=ylb",
        "iconUrl": "http://27.151.112.180:8005/xyzqylb2.1/images/splash/default/D7EAFF5AA4CA4093AC111.png",
        "linkType": "2"
      }
    ],
    "pollNews": 30,
    "enableTalkingdata": true,
    "enableBonree": true,
    "newsTitle": "投资参考",
    "useLocalSplash": true,
    "buttonList": [
      {
        "items": [
          {
            "detail": "",
            "title": "自选",
            "remark": "0",
            "imageUrl": "",
            "linkParam": "",
            "link": "3",
            "iconUrl": "http://27.151.112.180:8005/xyzqylb2.1/images/icon/20161226173818/45E3A189AC154007A9.png",
            "linkType": "1"
          },
          {
            "detail": "",
            "title": "行情",
            "remark": "0",
            "imageUrl": "",
            "linkParam": "",
            "link": "4",
            "iconUrl": "http://27.151.112.180:8005/xyzqylb2.1/images/icon/20161226173818/7B202842687D493F92.png",
            "linkType": "1"
          },
          {
            "detail": "",
            "title": "资讯",
            "remark": "0",
            "imageUrl": "",
            "linkParam": "",
            "link": "info/index.html",
            "iconUrl": "http://27.151.112.180:8005/xyzqylb2.1/images/icon/20161226173818/671B5D56A7C040DBBB.png",
            "linkType": "2"
          },
          {
            "detail": "",
            "title": "银证转帐",
            "remark": "1",
            "imageUrl": "",
            "linkParam": "",
            "link": "http://27.151.112.180:8005/ulb3/hallwap/biz/bank/sec/nav?channel=WAP_YLB_APP",
            "iconUrl": "http://27.151.112.180:8005/xyzqylb2.1/images/icon/20161226173818/C8DDDDB7D0A7415684.png",
            "linkType": "2"
          },
          {
            "detail": "",
            "title": "交易",
            "remark": "2",
            "imageUrl": "",
            "linkParam": "",
            "link": "12",
            "iconUrl": "http://27.151.112.180:8005/xyzqylb2.1/images/icon/20161226173818/A522D419376F425CA1.png",
            "linkType": "1"
          },
          {
            "detail": "",
            "title": "新股申购",
            "remark": "1",
            "imageUrl": "",
            "linkParam": "type=101",
            "link": "info/index.html",
            "iconUrl": "http://27.151.112.180:8005/xyzqylb2.1/images/icon/20161226173818/C8C473DDC4A746389E.png",
            "linkType": "2"
          },
          {
            "detail": "",
            "title": "业务办理",
            "remark": "1",
            "imageUrl": "",
            "linkParam": "",
            "link": "http://27.151.112.180:8005/ulb3/hallwap/index?channel=WAP_YLB_APP",
            "iconUrl": "http://27.151.112.180:8005/xyzqylb2.1/images/icon/20161226173818/5ED74595E6124B8692.png",
            "linkType": "2"
          },
          {
            "detail": "",
            "title": "开户",
            "remark": "0",
            "imageUrl": "",
            "linkParam": "url=http://wap.xyzq.com.cn/app/download/kh/xyzq_kh.apk",
            "link": "6",
            "iconUrl": "http://27.151.112.180:8005/xyzqylb2.1/images/icon/20161226173818/3A77D7C6ED9645378F.png",
            "linkType": "1"
          },
          {
            "detail": "",
            "title": "缠论结构",
            "remark": "0",
            "imageUrl": "",
            "linkParam": "",
            "link": "http://h5.test.icaikee.com/youlibaoXYv1/index.html",
            "iconUrl": "http://27.151.112.180:8005/xyzqylb2.1/images/icon/ico_cljg.png",
            "linkType": "2"
          },
          {
            "detail": "",
            "title": "牛人牛股",
            "remark": "0",
            "imageUrl": "",
            "linkParam": "",
            "link": "http://h5.test.icaikee.com/combineXYv1/index.html",
            "iconUrl": "http://27.151.112.180:8005/xyzqylb2.1/images/icon/ico_nrng.png",
            "linkType": "2"
          },
          {
            "detail": "",
            "title": "投资日历",
            "remark": "0",
            "imageUrl": "",
            "linkParam": "",
            "link": "http://h5.test.icaikee.com/themeXYv1/index.html",
            "iconUrl": "http://27.151.112.180:8005/xyzqylb2.1/images/icon/ico_tzrl.png",
            "linkType": "2"
          },
          {
            "detail": "",
            "title": "智能投顾",
            "remark": "0",
            "imageUrl": "",
            "linkParam": "",
            "link": "http://h5.test.icaikee.com//intelligentXYv1.0/index.html?from=singlemessage&isappinstalled=0",
            "iconUrl": "http://27.151.112.180:8005/xyzqylb2.1/images/icon/ico_zntg.png",
            "linkType": "2"
          }
        ],
        "banType": "5"
      },
      {
        "items": [
          {
            "detail": "",
            "title": "投资者教育",
            "remark": "",
            "imageUrl": "",
            "linkParam": "",
            "link": "http://27.151.112.180:8005/ylb2.0/teach/teach.html",
            "iconUrl": "http://27.151.112.180:8005/xyzqylb2.1/images/icon/20161226173818/1039ADC49EA045BA89.png",
            "linkType": "2"
          },
          {
            "detail": "",
            "title": "意见反馈",
            "remark": "",
            "imageUrl": "",
            "linkParam": "",
            "link": "8",
            "iconUrl": "http://27.151.112.180:8005/xyzqylb2.1/images/icon/20161226173818/E55ED16E25724B62A5.png",
            "linkType": "1"
          },
          {
            "detail": "",
            "title": "客服电话",
            "remark": "",
            "imageUrl": "",
            "linkParam": "phone=95562",
            "link": "11",
            "iconUrl": "http://27.151.112.180:8005/xyzqylb2.1/images/icon/20161226173818/F5C8670316BC424E90.png",
            "linkType": "1"
          },
          {
            "detail": "",
            "title": "免责声明",
            "remark": "",
            "imageUrl": "",
            "linkParam": "",
            "link": "10",
            "iconUrl": "http://27.151.112.180:8005/xyzqylb2.1/images/icon/20161226173818/1AB60970D6EF4E35A3.png",
            "linkType": "1"
          }
        ],
        "banType": "6"
      }
    ],
    "mallUrl": "http://27.151.112.180:8005/upc_view/dev_web2.1.0_test_integrate/spa/spa-require-ylb.html",
    "myself": {
      "fundAccUrl": "http://27.151.112.180:8005/upc_view/dev_web2.1.0_test_integrate/spa/spa-require-ylbaccountDetails.html",
      "xztAccUrl": "http://27.151.112.180:8005/upc_view/dev_web2.1.0_test_integrate/spa/spa-require-accountManage.html",
      "buttonList": [
        {
          "items": [
            {
              "detail": "",
              "title": "我的财富",
              "remark": "0",
              "imageUrl": "",
              "linkParam": "isulblogin=1",
              "link": "http://27.151.112.180:8005/ulb3/hallwap/wealth/index?channel=WAP_YLB_APP",
              "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/7B202842687D493F92.png",
              "linkType": "2" },
            {
              "detail": "",
              "title": "理财订单",
              "remark": "0",
              "imageUrl": "",
              "linkParam": "isulblogin=1",
              "link": "http://27.151.112.180:8005/upc_view/dev_web2.1.0_test_integrate/spa/spa-require-ylb-my-order.html",
              "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/7B202842687D493F92.png",
              "linkType": "2" },
            {
              "detail": "",
              "title": "银证转账",
              "remark": "0",
              "imageUrl": "",
              "linkParam": "isulblogin=1",
              "link": "http://27.151.112.180:8005/ulb3/hallwap/biz/bank/sec/nav?channel=WAP_YLB_APP",
              "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/671B5D56A7C040DBBB.png",
              "linkType": "2" }
          ],
          "banType": "8"
        },
        {
          "items": [
            {
              "detail": "",
              "title": "我的理财",
              "remark": "0",
              "imageUrl": "",
              "linkParam": "isulblogin=1",
              "link": "http://27.151.112.180:8005/upc_view/dev_web2.1.0_test_integrate/spa/spa-require-ylb-my-finance-prod.html",
              "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/7B202842687D493F92.png",
              "linkType": "2" },
            {
              "detail": "",
              "title": "我的定投",
              "remark": "0",
              "imageUrl": "",
              "linkParam": "isulblogin=1",
              "link": "http://27.151.112.180:8005/upc_view/dev_web2.1.0_test_integrate/spa/spa-require-ylb-my-adviser.html",
              "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/7B202842687D493F92.png",
              "linkType": "2" },
            {
              "detail": "",
              "title": "我的资讯",
              "remark": "0",
              "imageUrl": "",
              "linkParam": "isulblogin=1",
              "link": "http://27.151.112.180:8005/upc_view/dev_web2.1.0_test_integrate/spa/spa-require-ylb-my-info.html",
              "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/7B202842687D493F92.png",
              "linkType": "2" },
            {
              "detail": "",
              "title": "我的收藏",
              "remark": "0",
              "imageUrl": "",
              "linkParam": "isulblogin=1",
              "link": "http://27.151.112.180:8005/upc_view/dev_web2.1.0_test_integrate/spa/spa-require-ylb-my-collect-prod.html",
              "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/7B202842687D493F92.png",
              "linkType": "2" }
          ],
          "banType": "9"
        },
        {
          "items": [
            {
              "detail": "",
              "title": "业务办理",
              "remark": "0",
              "imageUrl": "",
              "linkParam": "",
              "link": "http://27.151.112.180:8005/ulb3/hallwap/index?channel=WAP_YLB_APP",
              "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/7B202842687D493F92.png",
              "linkType": "2" },
            {
              "detail": "",
              "title": "风险测评",
              "remark": "0",
              "imageUrl": "",
              "linkParam": "isulblogin=1",
              "link": "http://27.151.112.180:8005/ulb3/hallwap/biz/risk/index?channel=WAP_YLB_APP",
              "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/7B202842687D493F92.png",
              "linkType": "2" },
            {
              "detail": "",
              "title": "创业板转签",
              "remark": "0",
              "imageUrl": "",
              "linkParam": "isulblogin=1",
              "link": "http://27.151.112.180:8005/ulb3/hallwap/biz/chinanext/gemsignindex?channel=WAP_YLB_APP",
              "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/7B202842687D493F92.png",
              "linkType": "2" }
          ],
          "banType": "9"
        },
        {
          "items": [
            {
              "detail": "",
              "title": "好友分享",
              "remark": "0",
              "imageUrl": "",
              "linkParam": "title=优理宝&iconpath=&content=一站式金融体验,让你开启财富之门&jumpurl=http://wap.xyzq.com.cn/",
              "link": "22",
              "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/7B202842687D493F92.png",
              "linkType": "1" },
            {
              "detail": "",
              "title": "新手指引",
              "remark": "0",
              "imageUrl": "",
              "linkParam": "",
              "link": "23",
              "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/7B202842687D493F92.png",
              "linkType": "1" },
            {
              "detail": "",
              "title": "我要吐槽",
              "remark": "0",
              "imageUrl": "",
              "linkParam": "",
              "link": "8",
              "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/7B202842687D493F92.png",
              "linkType": "1" }
          ],
          "banType": "9"
        }
      ]
    },
    "trade": {
      "normalTrade": {
        "indexPage": {
          "buttonList": [ { "items": [ { "detail": "", "title": "买入", "remark": "0", "imageUrl": "", "linkParam": "", "link": "33", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/45E3A189AC154007A9.png", "linkType": "1" }, { "detail": "", "title": "卖出", "remark": "0", "imageUrl": "", "linkParam": "", "link": "34", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/7B202842687D493F92.png", "linkType": "1" }, { "detail": "", "title": "撤单", "remark": "0", "imageUrl": "", "linkParam": "", "link": "35", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/671B5D56A7C040DBBB.png", "linkType": "1" }, { "detail": "", "title": "资金股份", "remark": "1", "imageUrl": "", "linkParam": "", "link": "46", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/C8DDDDB7D0A7415684.png", "linkType": "1" }, { "detail": "", "title": "银证转账", "remark": "2", "imageUrl": "", "linkParam": "", "link": "https://estock.xyzq.com.cn/ulb/yzzz", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/A522D419376F425CA1.png", "linkType": "2" }, { "detail": "", "title": "委托查询", "remark": "1", "imageUrl": "", "linkParam": "", "link": "36", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/C8C473DDC4A746389E.png", "linkType": "1" }, { "detail": "", "title": "成交查询", "remark": "1", "imageUrl": "", "linkParam": "", "link": "37", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/5ED74595E6124B8692.png", "linkType": "1" }, { "detail": "", "title": "资金流水", "remark": "0", "imageUrl": "", "linkParam": "", "link": "38", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/3A77D7C6ED9645378F.png", "linkType": "1" } ], "banType": "5" }, { "items": [ { "detail": "", "title": "新股申购", "summary": { "formatText": "今日有%s只新股可申购", "formatDataType": "0" }, "remark": "0", "imageUrl": "", "linkParam": "", "link": "25", "iconUrl": "", "linkType": "1" }, { "detail": "", "title": "国债逆回购", "remark": "0", "imageUrl": "", "linkParam": "", "link": "170", "iconUrl": "", "linkType": "1" }, { "detail": "", "title": "现金理财", "remark": "0", "imageUrl": "", "linkParam": "", "link": "https://estock.xyzq.com.cn/ulb/xxxr", "iconUrl": "", "linkType": "2" } ], "banType": "7" }, { "items": [ { "detail": "", "title": "沪港通", "remark": "0", "imageUrl": "", "linkParam": "", "link": "68", "iconUrl": "", "linkType": "1" }, { "detail": "", "title": "深港通", "remark": "0", "imageUrl": "", "linkParam": "", "link": "158", "iconUrl": "", "linkType": "1" } ], "banType": "7" }, { "items": [ { "detail": "", "title": "场内基金", "summary": { "formatText": "支持实时深申赎货币基金" }, "remark": "0", "imageUrl": "", "linkParam": "", "link": "32", "iconUrl": "", "linkType": "1" }, { "detail": "", "title": "分级基金", "remark": "0", "imageUrl": "", "linkParam": "", "link": "32", "iconUrl": "", "linkType": "1" }, { "detail": "", "title": "跨境跨市ETF", "remark": "0", "imageUrl": "", "linkParam": "", "link": "32", "iconUrl": "", "linkType": "1" } ], "banType": "7" } ] },
        "qryFuncList": {
          "buttonList": [ { "items": [ { "detail": "", "title": "成交查询", "remark": "0", "imageUrl": "", "linkParam": "", "link": "37", "iconUrl": "", "linkType": "1" }, { "detail": "", "title": "委托查询", "remark": "0", "imageUrl": "", "linkParam": "", "link": "36", "iconUrl": "", "linkType": "1" } ], "banType": "7" }, { "items": [ { "detail": "", "title": "资金流水", "remark": "0", "imageUrl": "", "linkParam": "", "link": "38", "iconUrl": "", "linkType": "1" }, { "detail": "", "title": "交割单", "remark": "0", "imageUrl": "", "linkParam": "", "link": "40", "iconUrl": "", "linkType": "1" } ], "banType": "7" } ] },
        "moreMenu": {
          "buttonList": [ { "items": [ { "detail": "", "title": "报价回购", "remark": "0", "imageUrl": "", "linkParam": "", "link": "42", "iconUrl": "", "linkType": "1" }, { "detail": "", "title": "自主行权", "remark": "0", "imageUrl": "", "linkParam": "", "link": "43", "iconUrl": "", "linkType": "1" }, { "detail": "", "title": "网络投票", "remark": "0", "imageUrl": "", "linkParam": "", "link": "44", "iconUrl": "", "linkType": "1" } ], "banType": "7" }, { "items": [ { "detail": "", "title": "密码修改", "remark": "0", "imageUrl": "", "linkParam": "", "link": "45", "iconUrl": "", "linkType": "1" } ], "banType": "7" } ] }
      },
      "creditTrade": {
        "indexPage": {
          "buttonList": [ { "items": [ { "detail": "", "title": "担保品买入", "remark": "0", "imageUrl": "", "linkParam": "", "link": "80", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/45E3A189AC154007A9.png", "linkType": "1" }, { "detail": "", "title": "担保品卖出", "remark": "0", "imageUrl": "", "linkParam": "", "link": "81", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/7B202842687D493F92.png", "linkType": "1" }, { "detail": "", "title": "融资买入", "remark": "0", "imageUrl": "", "linkParam": "", "link": "82", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/671B5D56A7C040DBBB.png", "linkType": "1" }, { "detail": "", "title": "融资卖出", "remark": "1", "imageUrl": "", "linkParam": "", "link": "83", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/C8DDDDB7D0A7415684.png", "linkType": "1" }, { "detail": "", "title": "撤单", "remark": "2", "imageUrl": "", "linkParam": "", "link": "84", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/A522D419376F425CA1.png", "linkType": "1" }, { "detail": "", "title": "成交查询", "remark": "1", "imageUrl": "", "linkParam": "type=101", "link": "85", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/C8C473DDC4A746389E.png", "linkType": "1" }, { "detail": "", "title": "委托查询", "remark": "1", "imageUrl": "", "linkParam": "", "link": "86", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/5ED74595E6124B8692.png", "linkType": "1" }, { "detail": "", "title": "资产负债", "remark": "0", "imageUrl": "", "linkParam": "", "link": "87", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/3A77D7C6ED9645378F.png", "linkType": "1" } ], "banType": "5" }, { "items": [ { "detail": "", "title": "直接还款", "remark": "0", "imageUrl": "", "linkParam": "", "link": "88", "iconUrl": "", "linkType": "1" }, { "detail": "", "title": "卖券还款", "remark": "0", "imageUrl": "", "linkParam": "", "link": "89", "iconUrl": "", "linkType": "1" }, { "detail": "", "title": "直接还券", "remark": "0", "imageUrl": "", "linkParam": "", "link": "90", "iconUrl": "", "linkType": "1" }, { "detail": "", "title": "买券还券", "remark": "0", "imageUrl": "", "linkParam": "", "link": "91", "iconUrl": "", "linkType": "1" } ], "banType": "7" }, { "items": [ { "detail": "", "title": "担保品划转", "remark": "0", "imageUrl": "", "linkParam": "", "link": "92", "iconUrl": "", "linkType": "1" }, { "detail": "", "title": "两融标的/担保证券查询", "remark": "0", "imageUrl": "", "linkParam": "", "link": "93", "iconUrl": "", "linkType": "1" } ], "banType": "7" }, { "items": [ { "detail": "", "title": "银证转账", "remark": "0", "imageUrl": "", "linkParam": "", "link": "https://estock.xyzq.com.cn/ulb/yzzz", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/A522D419376F425CA1.png", "linkType": "2" }, { "detail": "", "title": "资金流水", "remark": "0", "imageUrl": "", "linkParam": "", "link": "95", "iconUrl": "", "linkType": "1" } ], "banType": "7" } ] },
        "qryFuncList": {
          "buttonList": [ { "items": [ { "detail": "", "title": "成交查询", "remark": "0", "imageUrl": "", "linkParam": "", "link": "85", "iconUrl": "", "linkType": "1" }, { "detail": "", "title": "委托查询", "remark": "0", "imageUrl": "", "linkParam": "", "link": "86", "iconUrl": "", "linkType": "1" } ], "banType": "7" }, { "items": [ { "detail": "", "title": "资产负债明细查询", "remark": "0", "imageUrl": "", "linkParam": "", "link": "96", "iconUrl": "", "linkType": "1" } ], "banType": "7" }, { "items": [ { "detail": "", "title": "资金流水查询", "remark": "0", "imageUrl": "", "linkParam": "", "link": "95", "iconUrl": "", "linkType": "1" }, { "detail": "", "title": "交割单", "remark": "0", "imageUrl": "", "linkParam": "", "link": "96", "iconUrl": "", "linkType": "1" } ], "banType": "7" } ] }
      },
      "hk2ShTrade": {
        "indexPage": {
          "buttonList": [ { "items": [ { "detail": "", "title": "买入", "remark": "0", "imageUrl": "", "linkParam": "", "link": "60", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/45E3A189AC154007A9.png", "linkType": "1" }, { "detail": "", "title": "卖出", "remark": "0", "imageUrl": "", "linkParam": "", "link": "61", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/7B202842687D493F92.png", "linkType": "1" }, { "detail": "", "title": "撤单", "remark": "0", "imageUrl": "", "linkParam": "", "link": "62", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/671B5D56A7C040DBBB.png", "linkType": "1" }, { "detail": "", "title": "资金股份", "remark": "1", "imageUrl": "", "linkParam": "", "link": "63", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/C8DDDDB7D0A7415684.png", "linkType": "1" } ], "banType": "5" }, { "items": [ { "detail": "", "title": "成交查询", "remark": "0", "imageUrl": "", "linkParam": "", "link": "64", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/45E3A189AC154007A9.png", "linkType": "1" }, { "detail": "", "title": "委托查询", "remark": "0", "imageUrl": "", "linkParam": "", "link": "65", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/45E3A189AC154007A9.png", "linkType": "1" }, { "detail": "", "title": "交割单", "remark": "0", "imageUrl": "", "linkParam": "", "link": "66", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/45E3A189AC154007A9.png", "linkType": "1" } ], "banType": "7" }, { "items": [ { "detail": "", "title": "交易日查询", "remark": "0", "imageUrl": "", "linkParam": "", "link": "67", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/45E3A189AC154007A9.png", "linkType": "1" }, { "detail": "", "title": "港股通开通", "remark": "0", "imageUrl": "", "linkParam": "", "link": "https://", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/45E3A189AC154007A9.png", "linkType": "2" } ], "banType": "7" } ] },
        "qryFuncList": {
          "buttonList": [ { "items": [ { "detail": "", "title": "成交查询", "remark": "0", "imageUrl": "", "linkParam": "", "link": "64", "iconUrl": "", "linkType": "1" }, { "detail": "", "title": "委托查询", "remark": "0", "imageUrl": "", "linkParam": "", "link": "65", "iconUrl": "", "linkType": "1" }, { "detail": "", "title": "交割单", "remark": "0", "imageUrl": "", "linkParam": "", "link": "66", "iconUrl": "", "linkType": "1" } ] } ] }
      },
      "hk2SzTrade": {
        "indexPage": {
          "buttonList": [ { "items": [ { "detail": "", "title": "买入", "remark": "0", "imageUrl": "", "linkParam": "", "link": "150", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/45E3A189AC154007A9.png", "linkType": "1" }, { "detail": "", "title": "卖出", "remark": "0", "imageUrl": "", "linkParam": "", "link": "151", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/7B202842687D493F92.png", "linkType": "1" }, { "detail": "", "title": "撤单", "remark": "0", "imageUrl": "", "linkParam": "", "link": "152", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/671B5D56A7C040DBBB.png", "linkType": "1" }, { "detail": "", "title": "资金股份", "remark": "1", "imageUrl": "", "linkParam": "", "link": "153", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/C8DDDDB7D0A7415684.png", "linkType": "1" } ], "banType": "5" }, { "items": [ { "detail": "", "title": "成交查询", "remark": "0", "imageUrl": "", "linkParam": "", "link": "154", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/45E3A189AC154007A9.png", "linkType": "1" }, { "detail": "", "title": "委托查询", "remark": "0", "imageUrl": "", "linkParam": "", "link": "155", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/45E3A189AC154007A9.png", "linkType": "1" }, { "detail": "", "title": "交割单", "remark": "0", "imageUrl": "", "linkParam": "", "link": "156", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/45E3A189AC154007A9.png", "linkType": "1" } ], "banType": "7" }, { "items": [ { "detail": "", "title": "交易日查询", "remark": "0", "imageUrl": "", "linkParam": "", "link": "157", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/45E3A189AC154007A9.png", "linkType": "1" }, { "detail": "", "title": "港股通开通", "remark": "0", "imageUrl": "", "linkParam": "", "link": "https://", "iconUrl": "https://estock.xyzq.com.cn/static/images/icon/20161226182503/45E3A189AC154007A9.png", "linkType": "2" } ], "banType": "7" } ] },
        "qryFuncList": {
          "buttonList": [ { "items": [ { "detail": "", "title": "成交查询", "remark": "0", "imageUrl": "", "linkParam": "", "link": "154", "iconUrl": "", "linkType": "1" }, { "detail": "", "title": "委托查询", "remark": "0", "imageUrl": "", "linkParam": "", "link": "155", "iconUrl": "", "linkType": "1" }, { "detail": "", "title": "交割单", "remark": "0", "imageUrl": "", "linkParam": "", "link": "156", "iconUrl": "", "linkType": "1" } ] } ] }
      }
    }
  },
  "respHead": {
    "details": "成功",
    "code": "0"
  }
}

Gson 是google解析Json的一个开源框架,同类的框架fastJson,JackJson等等
本人fastJson用了两年,也是从去年才开始接触Gson,希望下面的总结会对博友有用,至于Gson与FastJson的对比,其实半斤八两的问题,不再赘述
第一步:在AS下面创建Java工程 并添加gson依赖
compile ‘com.google.code.gson:gson:2.6.2’
Gson解析JSON数据实例_第2张图片

解析实例:

Gson gson = new Gson();
                    RespAppTradeConfig response = gson.fromJson(resp, RespAppTradeConfig.class);

                    //解析数据
                    List gridFunc = getBanData(response.getRespBody().getTrade().getNormalTrade().getIndexPage().getButtonList(), Consts.BanType.GRIDFUNC);

以下是RespAppTradeConfig 类

public class RespAppTradeConfig extends RespBaseOld {
    private RespbodyBean respBody;

    public RespbodyBean getRespBody() {
        return respBody;
    }

    public void setRespBody(RespbodyBean respBody) {
        this.respBody = respBody;
    }

    public static class RespbodyBean {
        private TradeBean trade;
        private MyselfBean myself;

        private String timestamp;
        private String recommendIcon;
        private String newsTitle;
        private int pollNews;
        private List buttonList;
        private List splash;
        private boolean enableTalkingdata;
        private boolean enableBonree;
        private boolean enableTingyun;
        private String mallUrl;

        public String getMallUrl() {
            return mallUrl;
        }

        public void setMallUrl(String mallUrl) {
            this.mallUrl = mallUrl;
        }


        public boolean isEnableTingyun() {
            return enableTingyun;
        }

        public void setEnableTingyun(boolean enableTingyun) {
            this.enableTingyun = enableTingyun;
        }

        public boolean isEnableTalkingdata() {
            return enableTalkingdata;
        }

        public void setEnableTalkingdata(boolean enableTalkingdata) {
            this.enableTalkingdata = enableTalkingdata;
        }

        public boolean isEnableBonree() {
            return enableBonree;
        }

        public void setEnableBonree(boolean enableBonree) {
            this.enableBonree = enableBonree;
        }

        public List getSplash() {
            return splash;
        }

        public void setSplash(List splash) {
            this.splash = splash;
        }

        public String getTimestamp() {
            return timestamp;
        }

        public void setTimestamp(String timestamp) {
            this.timestamp = timestamp;
        }

        public String getRecommendIcon() {
            return recommendIcon;
        }

        public void setRecommendIcon(String recommendIcon) {
            this.recommendIcon = recommendIcon;
        }

        public String getNewsTitle() {
            return newsTitle;
        }

        public void setNewsTitle(String newsTitle) {
            this.newsTitle = newsTitle;
        }

        public int getPollNews() {
            return pollNews;
        }

        public void setPollNews(int pollNews) {
            this.pollNews = pollNews;
        }

        public List getButtonList() {
            return buttonList;
        }

        public void setButtonList(List buttonList) {
            this.buttonList = buttonList;
        }

        public TradeBean getTrade() {
            return trade;
        }

        public void setTrade(TradeBean trade) {
            this.trade = trade;
        }

        public MyselfBean getMyself() {
            return myself;
        }

        public void setMyself(MyselfBean myself) {
            this.myself = myself;
        }
    }

    public static class MyselfBean{
        private String fundAccUrl;
        private String xztAccUrl;
        private List buttonList;

        public String getFundAccUrl() {
            return fundAccUrl;
        }

        public void setFundAccUrl(String fundAccUrl) {
            this.fundAccUrl = fundAccUrl;
        }

        public String getXztAccUrl() {
            return xztAccUrl;
        }

        public void setXztAccUrl(String xztAccUrl) {
            this.xztAccUrl = xztAccUrl;
        }

        public List getButtonList() {
            return buttonList;
        }

        public void setButtonList(List buttonList) {
            this.buttonList = buttonList;
        }
    }

    public static class TradeBean{
        private NormalTradeBean normalTrade;
        private CreditTradeBean creditTrade;
        private Hk2ShTradeBean hk2ShTrade;
        private Hk2SzTradeBean hk2SzTrade;

        public NormalTradeBean getNormalTrade() {
            return normalTrade;
        }

        public void setNormalTrade(NormalTradeBean normalTrade) {
            this.normalTrade = normalTrade;
        }

        public CreditTradeBean getCreditTrade() {
            return creditTrade;
        }

        public void setCreditTrade(CreditTradeBean creditTrade) {
            this.creditTrade = creditTrade;
        }

        public Hk2ShTradeBean getHk2ShTrade() {
            return hk2ShTrade;
        }

        public void setHk2ShTrade(Hk2ShTradeBean hk2ShTrade) {
            this.hk2ShTrade = hk2ShTrade;
        }

        public Hk2SzTradeBean getHk2SzTrade() {
            return hk2SzTrade;
        }

        public void setHk2SzTrade(Hk2SzTradeBean hk2SzTrade) {
            this.hk2SzTrade = hk2SzTrade;
        }
    }

    public static class NormalTradeBean{
        private IndexPageBean indexPage;
        private QryFuncListBean qryFuncList;
        private MoreMenuBean moreMenu;

        public IndexPageBean getIndexPage() {
            return indexPage;
        }

        public void setIndexPage(IndexPageBean indexPage) {
            this.indexPage = indexPage;
        }

        public QryFuncListBean getQryFuncList() {
            return qryFuncList;
        }

        public void setQryFuncList(QryFuncListBean qryFuncList) {
            this.qryFuncList = qryFuncList;
        }

        public MoreMenuBean getMoreMenu() {
            return moreMenu;
        }

        public void setMoreMenu(MoreMenuBean moreMenu) {
            this.moreMenu = moreMenu;
        }
    }

    public static class CreditTradeBean{
        private IndexPageBean indexPage;
        private QryFuncListBean qryFuncList;

        public IndexPageBean getIndexPage() {
            return indexPage;
        }

        public void setIndexPage(IndexPageBean indexPage) {
            this.indexPage = indexPage;
        }

        public QryFuncListBean getQryFuncList() {
            return qryFuncList;
        }

        public void setQryFuncList(QryFuncListBean qryFuncList) {
            this.qryFuncList = qryFuncList;
        }
    }

    public static class Hk2ShTradeBean{
        private IndexPageBean indexPage;
        private QryFuncListBean qryFuncList;

        public IndexPageBean getIndexPage() {
            return indexPage;
        }

        public void setIndexPage(IndexPageBean indexPage) {
            this.indexPage = indexPage;
        }

        public QryFuncListBean getQryFuncList() {
            return qryFuncList;
        }

        public void setQryFuncList(QryFuncListBean qryFuncList) {
            this.qryFuncList = qryFuncList;
        }
    }

    public static class Hk2SzTradeBean{
        private IndexPageBean indexPage;
        private QryFuncListBean qryFuncList;

        public IndexPageBean getIndexPage() {
            return indexPage;
        }

        public void setIndexPage(IndexPageBean indexPage) {
            this.indexPage = indexPage;
        }

        public QryFuncListBean getQryFuncList() {
            return qryFuncList;
        }

        public void setQryFuncList(QryFuncListBean qryFuncList) {
            this.qryFuncList = qryFuncList;
        }
    }

    public static class IndexPageBean{
        private List buttonList;

        public List getButtonList() {
            return buttonList;
        }

        public void setButtonList(List buttonList) {
            this.buttonList = buttonList;
        }
    }

    public static class QryFuncListBean{
        private List buttonList;

        public List getButtonList() {
            return buttonList;
        }

        public void setButtonList(List buttonList) {
            this.buttonList = buttonList;
        }
    }

    public static class MoreMenuBean{
        private List buttonList;

        public List getButtonList() {
            return buttonList;
        }

        public void setButtonList(List buttonList) {
            this.buttonList = buttonList;
        }
    }
}

方法getBanData

private static List getBanData(List areaConfigList, String type) {
        //过滤空数据
        if (areaConfigList == null || areaConfigList.size() == 0)
            return null;

        List output = new ArrayList();
        for (AreaConfigInfo areaItem : areaConfigList) {
            if (areaItem.getBanType().equals(type)) {
                //过滤空数据
                if (areaItem.getItems() == null || areaItem.getItems().size() == 0)
                    break;

                for (AreaConfigInfo.ItemsBean item : areaItem.getItems()) {
                    SuperLink target = new SuperLink();
                    target.mTitle = item.getTitle();
                    target.mDetail = item.getDetail();
                    target.mRemark = item.getRemark();
                    target.mLink = item.getLink();
                    target.mLinkType = item.getLinkType();
                    target.mLinkParam = item.getLinkParam();
                    target.mIconUrl = item.getIconUrl();
                    target.mIconUrl2 = item.getImageUrl();
                    output.add(target);
                }
            }
        }

        return output;
    }

AreaConfigInfo类

public class AreaConfigInfo {
    private String banType;
    private List items;

    public String getBanType() {
        return banType;
    }

    public void setBanType(String banType) {
        this.banType = banType;
    }

    public List getItems() {
        return items;
    }

    public void setItems(List items) {
        this.items = items;
    }

    public static class ItemsBean {
        private String detail;
        private String iconUrl;
        private String imageUrl;
        private String link;
        private String linkParam;
        private String linkType;
        private String remark;
        private String title;

        public String getDetail() {
            return detail;
        }

        public void setDetail(String detail) {
            this.detail = detail;
        }

        public String getIconUrl() {
            return iconUrl;
        }

        public void setIconUrl(String iconUrl) {
            this.iconUrl = iconUrl;
        }

        public String getImageUrl() {
            return imageUrl;
        }

        public void setImageUrl(String imageUrl) {
            this.imageUrl = imageUrl;
        }

        public String getLink() {
            return link;
        }

        public void setLink(String link) {
            this.link = link;
        }

        public String getLinkParam() {
            return linkParam;
        }

        public void setLinkParam(String linkParam) {
            this.linkParam = linkParam;
        }

        public String getLinkType() {
            return linkType;
        }

        public void setLinkType(String linkType) {
            this.linkType = linkType;
        }

        public String getRemark() {
            return remark;
        }

        public void setRemark(String remark) {
            this.remark = remark;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }
    }
}

序列化类SuperLink


public class SuperLink implements Serializable{
    public String mTitle        = "";
    public String mDetail       = "";
    public String mRemark       = "";
    public String mLink         = "";
    public String mLinkType     = "";
    public String mLinkParam    = "";
    public Object mIconUrl      = "";
    public Object mIconUrl2     = "";

    public void goTarget(Context context) {
        goTarget(context, false);
    }

    public void goTarget(Context context, boolean silence) {
        //弹框
        if (isAlertLink()) {
            XYZQUtils.showCommDialog(context, mTitle, mDetail);
        } 
        //本地原生页面
        else if (isPageLink()) {
            PageMap pageMap = new  PageMap(context, mLink);
            if (pageMap.isPageKeyValid()) {
                HashMap params = XYZQUtils.SplitParams(mLinkParam);
                params.put("INNER_TITLE", mTitle);//某些页面需要传递标题,所以通过这个变量透传
                pageMap.gotoPage(params);
            } else {
                if (!silence)
                    ToastUtils.show(context.getApplicationContext(), "功能建设中");
            }
        } 
        //用通用Webview页面打开网页
        else if (isWebviewLink()) {
            //过滤无网络的情况
            if (!PhoneUtils.hasInternet(context)){
                if (!silence)
                    ToastUtils.show(context, context.getResources().getString(R.string.error_connect));
                return;
            }

            //过滤数据异常
            if (TextUtils.isEmpty(mLink)){
                if (!silence)
                    ToastUtils.show(context.getApplicationContext(), "功能建设中");
                return;
            }

            /**
             * 临时页面: 如果是暴打产品汪的网页,则用系统浏览器打开
             */
            if (getUrl().contains("appbdcpw.html")){
                try {
                    Uri uri = Uri.parse(getUrl());  
                    Intent it = new Intent(Intent.ACTION_VIEW, uri);  
                    context.startActivity(it);
                } catch (Exception e) {
                    e.printStackTrace();
                    ToastUtils.show(context, "暴打产品汪页面打开失败");
                }

                return;
            }

            Intent intent = new Intent(context, CommonWebViewActivity.class);
            intent.putExtra("URL", getUrl());
            context.startActivity(intent);
        }
        else if (isExternWebviewLink()) {
            //过滤无网络的情况
            if (!PhoneUtils.hasInternet(context)){
                if (!silence)
                    ToastUtils.show(context, context.getResources().getString(R.string.error_connect));
                return;
            }

            //过滤数据异常
            if (TextUtils.isEmpty(mLink)){
                if (!silence)
                    ToastUtils.show(context.getApplicationContext(), "功能建设中");
                return;
            }

            //打开网页
            try {
                Uri uri = Uri.parse(getUrl());  
                Intent it = new Intent(Intent.ACTION_VIEW, uri);  
                context.startActivity(it);
            } catch (Exception e) {
                e.printStackTrace();
                if (!silence)
                    ToastUtils.show(context.getApplicationContext(), "功能建设中");
            }
        }
        else {
            if (!silence)
                ToastUtils.show(context.getApplicationContext(), "功能建设中");
        }
    }

    private String getUrl() {
        if (TextUtils.isEmpty(mLink)){
            return "";
        }

        //无参数,直接访问Link
        if (TextUtils.isEmpty(mLinkParam)){
            return mLink;
        }

        //如果有params,就拼凑下
        //如果有问号,就用&拼接
        if (mLink.contains("?")){
            return mLink + "&" + mLinkParam;
        }
        //如果无问号,就加个问号在拼接
        else{
            return mLink + "?" + mLinkParam;
        }
    }

    public boolean isLinkLegal(Context context) {
        if (isPageLink()) {
            PageMap pageMap = new PageMap(context, mLink);
            return pageMap.isPageKeyValid();
        }
        return true;
    }

    private boolean isAlertLink() {
        return mLinkType != null && mLinkType.equalsIgnoreCase("0");
    }

    private boolean isPageLink() {
        return mLinkType != null && mLinkType.equalsIgnoreCase("1");
    }

    private boolean isWebviewLink() {
        return mLinkType != null && mLinkType.equalsIgnoreCase("2");
    }

    private boolean isExternWebviewLink() {
        return mLinkType != null && mLinkType.equalsIgnoreCase("3");
    }

    public final static String INNER_TITLE = "INNER_TITLE";
}

从上面的解析过程中,需要特别注意的是每一个参数名必须与数据的字段名一致,不然是解析不到结果的。数据都是一层一层的获取的,每一层数据都写对应的数据封装类Bean再使用对应的get方法获取到对应的数据,重要的事情再说一遍,Bean里面的参数必须与JSON字符串的字段是一致的,否则解析不到数据,得到的是一个空结果集。

你可能感兴趣的:(项目开发)