{"files": {"Chrysanthemum.jpg": "Chrysanthemum.jpg", "index.html": "index.html", "1234.rmvb": "1234.rmvb", "apache_pb22_ani.gif": "apache_pb22_ani.gif", "123.mp4": "123.mp4", "sample_h264_1mbit.mp4": "sample_h264_1mbit.mp4", "1234.mp4": "1234.mp4", "apache_pb22.gif": "apache_pb22.gif", "test.doc": "test.doc", "apache_pb.gif": "apache_pb.gif", "testppt.pptx": "testppt.pptx", "love.mp3": "love.mp3", "apache_pb.png": "apache_pb.png", "sample_100kbit.mov": "sample_100kbit.mov", "apache_pb22.png": "apache_pb22.png", "receivetest.log": "receivetest.log", "111.docx": "111.docx", "test.txt": "test.txt"}, "dirs": {"receive": "receive", "test file": "test file"}}
假设这段数据,获取其中的files,不是value,是key

解决方案 »

  1.   

    看你的数据key和value都是一样的数据,为什么要这样弄呢
      

  2.   

    看你的数据key和value都是一样的数据,为什么要这样弄呢
      

  3.   

    我说的是files,dirs,这些是不固定的
      

  4.   

    你可以放入键固定,然后根据key来读取这files,dirs两个灵活的值行吗?
      

  5.   

    那得自己写解析的方法,:号前面的为Key,全部保存下来
      

  6.   

    private String[] analyzeJsonToArray(JSONObject jsonject, String type) { String string = jsonject.toString();
    string = string.replace("}", "");
    string = string.replace("{", "");
    string = string.replace("\"", "");
    String[] strings = string.split(",");

    if (type.equals("key")) {
    String[] strings0 = new String[strings.length];
    for (int i = 0; i < strings.length; i++) {
    strings0[i] = strings[i].split(":")[0];
    }
    return strings0;
    } else if (type.equals("value")) {
    String[] strings1 = new String[strings.length];
    for (int i = 0; i < strings.length; i++) {
    strings1[i] = strings[i].split(":")[1];
    }
    return strings1;
    } else {
    return null;
    }
    }
      

  7.   

    for(var key in json){   alert(key);}