1

below code is my JSON file and i want to read this data from server so how can i read these data by using JSONObject in andorid

this code contain array identifier beginning itself without name identifier of array


[
    {
        "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
    },
]
Sathish
  • 1,147
  • 3
  • 10
  • 20
  • This question was answered before [Check here][1] [And here][2] [1]: http://stackoverflow.com/questions/2818697/sending-and-parsing-json-in-android [2]: http://stackoverflow.com/questions/9605913/how-to-parse-json-in-android – iTech Nov 11 '12 at 16:11
  • that above links doesn't reach my goal of JSON.. My code contain array beginning itself without JSONArray name – Sathish Nov 11 '12 at 16:27

1 Answers1

1

You can read this directly into JSONArray not JSONObject

JSONArray jsonArray = new JSONArray(dataString);

I have tried it with your provided JSON data and it worked fine.

iTech
  • 18,192
  • 4
  • 57
  • 80