-1

我的 JSON 响应如下:

["Sting - We Work The Black Seam",
"Bob Marley - No woman no cry",
"Bob Marley - Redemption song",
"Peter Gabriel - Solsbury Hill",
"Elton John - Candle in the wind",
"Elton John - I'm still standing",
"Bernard Lavilliers - Noir et blanc",
"Michel Polnareff - Love me"]

首先让我知道它是否是正确的 JSON。如果是这样,那么如何阅读此信息..?? 因为它没有任何数组甚至单个元素的名称。

谢谢大家。。现在知道怎么办了。。

    public ArrayList<String> createPlaylist(String result) {
        try {
            json = new JSONArray(result);
            System.out.println("Json Values : " + json);
        } catch (JSONException e) {
            e.printStackTrace();
        }           
        ArrayList<String> list = new ArrayList<String>();
        if (json != null) {
            int len = json.length();
            for (int i = 0; i < len; i++) {
                try {
                    list.add(json.get(i).toString());
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }
        return list;
    }

这是正确的..请让我知道..

问候, 穆尼卡

4

2 回答 2

0

It is valid JSON. You can check this online at http://jsonformatter.curiousconcept.com/

To read it in JavaScript, you access it like an array. If you are getting it as a string then you need to parse it into a valid JavaScript construct using something the JSON library found at: https://github.com/douglascrockford/JSON-js

E.g.

var myData = JSON.parse(myJSONString);
var elem = myData[0];
于 2012-05-18T09:57:35.150 回答
0

这是一个有效的 JSON。

试试这个来可视化:http: //jsonviewer.stack.hu/

于 2012-05-18T09:57:11.323 回答