我有這個字符串是從應用程序引擎數據存儲上的「ContactInfo」實體中提取的,並且它包含了每個類型的所有子項的字符串。任何人對如何解析這個問題或者以一種有序的方式來組織它都有很好的想法。我需要它爲每個條目顯示名字,姓氏,地址等,併爲每個人分別顯示。解析Android中的字符串
這是字符串日誌爲:
08-30 17:22:03.802: W/apples(18160): {"items":[{"description":"payment confirmed","emailAddress":"[email protected]","id":"Fri Aug 30 17:20:35 EDT 2013","nameFirst":"Bill","nameLast":"Sanders","phone":"5555555555","state":"KS","streetAddress":"123 Rick Dr","zipCode":"44444","kind":"contactinfoendpoint#resourcesItem"},{"description":"payment confirmed","emailAddress":"[email protected]","id":"Fri Aug 30 17:21:37 EDT 2013","nameFirst":"Frank","nameLast":"Lloyd","phone":"5554567896","state":"KY","streetAddress":"999 Rock St","zipCode":"44555","kind":"contactinfoendpoint#resourcesItem"}],"kind":"contactinfoendpoint#resources","etag":"\"NiDXI3T89oRrAPGJAhgGQje1Z0w/z0W4p01mjHc5cNgcOt3Kb_1xo8E\""}
這是有效的JSON。使用json解析器。 –
Sotirios說什麼,並投票結束。選擇[org.json](http://www.json.org/javadoc/),[gson](http://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google /gson/Gson.html)或我最喜歡的[jackson](http://fasterxml.github.io/jackson-core/javadoc/2.2.0/)。 – Mena
@SotiriosDelimanolis謝謝,我會研究一下。我需要什麼類型的適配器才能讓每個條目出現在listView或類似的東西中? – johnsonjp34