Search code examples
androidjsonparsinggetjson

I am not able to Parse the json file. It begins with array


The following JSON starts with an array type which I am having a lots of problem to Parse. Please help.

[{"type":"1","name":"ABC","start_date":"5","end_date":null,"time":"00:00:00","description":"abc","venue":"","v_id":"1","c1name":"","c1phno":"","c1email":"","c2name":"","c2phno":"","c2email":""}]

Please help me out if possible.


Solution

  • Are you trying to get the data as a JSONArray?

    It would look like this:

      String json = "your json data";
      JSONArray jsonArray = new JSONArray(json);
      JSONObject jsonObject = jsonArray.getJSONObject(0);
    
      String type = jsonObject.getString("type");
      String name = jsonObject.getString("name");
    

    And so on...