使用JSONObject 读取 jason对象中的key

JSONObject  这个是读取json串开头的  {

JSONArray    这个是读取json中的数组   [

上面两个要注意一下,

 

String str=“{["abc"123,]}”  //假设     

 

读取json的key值

 String regEx = "[0-9]+";   // 过滤value值

JSONObject jsonObject = JSONObject.fromObject(sb.toString());
            JSONArray JsonArray =jsonObject.getJSONArray("prism_wordsInfo");
            System.out.println(JsonArray);
            for( Object str1  : JsonArray){
                JSONObject jsonObject1 = JSONObject.fromObject(str1);
                String bb=jsonObject1.getString("word");
               // System.out.println("word "+bb);  
                if(bb.matches(regEx)){
                    System.out.println("word "+bb);  
                }
            }

你可能感兴趣的:(使用JSONObject 读取 jason对象中的key)