如何在Linux中将searalized字符串转换为json对象

时间:2012-11-11 16:08:35

标签: json

下面的代码是我的JSON文件,我想从服务器读取这些数据,以便如何在andorid中使用JSONObject读取这些数据

此代码包含数组标识符,其自身没有数组的名称标识符


[
    {
        "created_at": "Sat Nov 10 12:00:26 +0000 2012",
        "id": 267235264374640640,
        "id_str": "267235264374640640",
        "text": "My text",
        "user": {
            "id": 166551306,
            "id_str": "166551306",
            "name": "John ",
            "location": "Chennai, India",
            "url": null,
            "notifications": null
          },
        "geo": null,
        "coordinates": null,
        "place": null,
        "contributors": null,
        "retweet_count": 0,
        "entities": {
            "hashtags": [],
            "urls": [],
            "user_mentions": []
        },
        "favorited": false,
        "retweeted": false
    },
   {
        "created_at": "Sat Nov 10 12:00:26 +0000 2012",
        "id": 267235264374640640,
        "id_str": "267235264374640640",
        "text": "My text",
        "user": {
            "id": 166551306,
            "id_str": "166551306",
            "name": "John ",
            "location": "Chennai, India",
            "url": null,
            "notifications": null
          },
        "geo": null,
        "coordinates": null,
        "place": null,
        "contributors": null,
        "retweet_count": 0,
        "entities": {
            "hashtags": [],
            "urls": [],
            "user_mentions": []
        },
        "favorited": false,
        "retweeted": false
    },
]

1 个答案:

答案 0 :(得分:1)

您可以直接将其读入 JSONArray 而不是 JSONObject

JSONArray jsonArray = new JSONArray(dataString);

我已经使用您提供的JSON数据进行了尝试,但它运行良好。