關於數群組類型的json解析方法

來源:互聯網
上載者:User

標籤:android   style   java   os   資料   io   html   ar   

遇到了很奇葩的數群組類型的json,一時解析不出來,用jsonObject會直接報錯。

Json資料如:

[{"id":"1000142","name":"\u5168\u90e8\u7c7b\u578b","subMenu":[{"id":"1000135","name":"\u591a\u5a92\u4f53\u8bbe\u8ba1"},{"id":"1000137","name":"java\u5f00\u53d1"},{"id":"1000138","name":"\u524d\u7aef\u5f00\u53d1"},{"id":"1000139","name":"php\u5f00\u53d1"},{"id":"1000140","name":"IOS\u5f00\u53d1"},{"id":"1000141","name":"android\u5f00\u53d1"}]},{"id":"1000143","name":"\u5168\u90e8\u7b49\u7ea7","subMenu":[{"id":"1000146","name":"\u9ad8\u7ea7"},{"id":"1000145","name":"\u4e2d\u7ea7"},{"id":"1000144","name":"\u521d\u7ea7"}]}]

解決方案:

Type listmenu = new TypeToken<ArrayList<ListMenu>>(){}.getType();List<ListMenu> menuPage=new Gson().fromJson(json, listmenu);


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.