Retrieving values from nested JSON Object

后端 未结 6 1285
星月不相逢
星月不相逢 2020-12-02 19:37

I\'ve got JSON file, which I want to parse. The JSON file (\"myfile\") has format as follows:

{
    \"LanguageLevels\": {
        \"1\": \"Początkujący\",
           


        
6条回答
  •  悲&欢浪女
    2020-12-02 19:59

    You can see that JSONObject extends a HashMap, so you can simply use it as a HashMap:

    JSONObject jsonChildObject = (JSONObject)jsonObject.get("LanguageLevels");
    for (Map.Entry in jsonChildOBject.entrySet()) {
        System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
    }
    

提交回复
热议问题