Json键值对

var people = {

    "programmers": [{

        "firstName": "Brett",

        "lastName": "McLaughlin",

        "email": "aaaa"

    }, {

        "firstName": "Jason",

        "lastName": "Hunter",

        "email": "bbbb"

    }, {

        "firstName": "Elliotte",

        "lastName": "Harold",

        "email": "cccc"

    }],

    "authors": [{

        "firstName": "Isaac",

        "lastName": "Asimov",

        "genre": "sciencefiction"

    }, {

        "firstName": "Tad",

        "lastName": "Williams",

        "genre": "fantasy"

    }, {

        "firstName": "Frank",

        "lastName": "Peretti",

        "genre": "christianfiction"

    }],

    "musicians": [{

        "firstName": "Eric",

        "lastName": "Clapton",

        "instrument": "guitar"

    }, {

        "firstName": "Sergei",

        "lastName": "Rachmaninoff",

        "instrument": "piano"

    }]

};

//获取数据

(待验证)

json格式如下:{"response":{"data":[{"address":"南京市游乐园","province":"江苏","district":"玄武区","city":"南京"}]},"status":"ok"}
希望得到结果是: 江苏 南京 玄武区 南京市游乐园

JSONObjectdataJson=new JSONObject("你的Json数据“);
JSONObject response=dataJson.getJSONObject("response");

JSONArraydata=response.getJSONArray("data");
JSONObject info=data.getJSONObject(0);
Stringprovince=info.getString("province");
String city=info.getString("city");
Stringdistrict=info.getString("district");
Stringaddress=info.getString("address");
System.out.println(province+city+district+address);

你可能感兴趣的:(java,Asp.net)