Json字符串Hashmap解析使用QuickJson



我使用快速Json解析Json字符串的格式检索所有歌曲的标题

{"response": {"status": {"version": "4.2", "code": 0, "message": "Success"}, "songs": [{"artist_id": "ARJHCSL123E29C21E8", "id": "SOENBWC13E58ECFBDD", "artist_name": "Bruno Mars", "title": "Grenade (En Vivo @ SXM)"}, {"artist_id": "ARJHCSL123E29C21E8", "id": "SOHQYKB130516E0C3B", "artist_name": "Bruno Mars", "title": "Bruno Mars - Just The Way You Are (Lee Wright Remix)"}, {"artist_id": "ARJHCSL123E29C21E8", "id": "SOFGCTK13DBAFD643B", "artist_name": "Bruno Mars", "title": "Young, Wild & Free (Originally Performed By Snoop Dogg, Wiz Khalifa) [Karaoke Version]"}, {"artist_id": "ARJHCSL123E29C21E8", "id": "SOJGNLU12C0DD05554", "artist_name": "Bruno Mars", "title": "GRENADE (Clean)/(CONTENT!)"}, {"artist_id": "ARJHCSL123E29C21E8", "id": "SOQJPOT13E58EA39D4", "artist_name": "Bruno Mars", "title": "Just The Way You Are (En Vivo @ SXM)"}, {"artist_id": "ARJHCSL123E29C21E8", "id": "SOBXSGM1468D0E25AD", "artist_name": "Bruno Mars", "title": "Locked Out Of Heaven - Manhattan's XOYO Mix"}, {"artist_id": "ARJHCSL123E29C21E8", "id": "SOIVCUQ13D3EE80CED", "artist_name": "Bruno Mars", "title": "Nothing On You"}, {"artist_id": "ARJHCSL123E29C21E8", "id": "SOKLXMU12AF72A8FE6", "artist_name": "Bruno Mars", "title": "Count On Me (EP Version)"}, {"artist_id": "ARJHCSL123E29C21E8", "id": "SOXHAGE1340BBA40EC", "artist_name": "Bruno Mars", "title": "Just The Way You Are (Carl Louis & Martin Danielle Classic Mix)"}, {"artist_id": "ARJHCSL123E29C21E8", "id": "SOMYEUN141E947704E", "artist_name": "Bruno Mars", "title": "Grenade (Michael Meds Mix)"}, {"artist_id": "ARJHCSL123E29C21E8", "id": "SOTSIBX136C2EE52F3", "artist_name": "Bruno Mars", "title": "DJ T Finguz Cadillac MIX"}, {"artist_id": "ARJHCSL123E29C21E8", "id": "SOVSSEW1312FDFC23C", "artist_name": "Bruno Mars", "title": "The Lazy Song (Official Remix)"}, {"artist_id": "ARJHCSL123E29C21E8", "id": "SOTUEIS135A61E6B89", "artist_name": "Bruno Mars", "title": "Just the Way You Are (Ultrafunk Dance Remix)"}, {"artist_id": "ARJHCSL123E29C21E8", "id": "SOAFTQW13EB2D8A84F", "artist_name": "Bruno Mars", "title": "This Is My Love (Victor Magan Remix)"}, {"artist_id": "ARJHCSL123E29C21E8", "id": "SORCBZR14491454F1C", "artist_name": "Bruno Mars", "title": "Locked Out of Heaven (Sultan and Ned Shepard Remix) [Radio Edit]"}]}}

我正在使用的API是歌曲API。我试图解析哈希映射,但我得到null。如果有人能告诉我如何解析hashmap以获得标题

        JsonParserFactory factory=JsonParserFactory.getInstance();
        JSONParser parser = factory.newJsonParser();
        Map jsonData=parser.parseJson(StringJson);
        String f = (String)jsonData.get("response");

下面给出了所有标题的列表:

  List f =  (List) (((Map) jsonData.get("response")).get("songs"));
   Iterator iter =   f.iterator();
  while(iter.hasNext()){
     System.out.println(((Map) iter.next()).get("title"));
  }

最新更新