-4

I have a problem. I have a String result. this result look like JsonArray but didnt convert to JsonArray. How can i do?

Here is my String:

{
    "PositionList": [{
        "Id": "56fd111c7283763f941b8cbd",
        "PlateNumber": "34GS1919",
        "PositionRefNo": "00264",
        "LoadingDate": "2016-03-31T14:59:58.967+03:00",
        "DepartureCityName": "İSTANBUL",
        "DepartureCountyName": "",
        "ArrivalCityName": "İSTANBUL",
        "ArrivalCountyName": "",
        "LoadCount": 1
    }],
    "Status": true,
    "Message": "",
    "LoginUserInfo": {
        "Id": "572856007507d911d04433f8",
        "UserName": "surucu1",
        "Name": "Sürücü",
        "Surname": "1"
    },
    "LoginDriverInfo": {
        "Id": "537d96fbf4531a24440e6eba",
        "Name": "joe",
        "Surname": "fun"
    }
}
urgas9
  • 806
  • 9
  • 22
user65505
  • 7
  • 5
  • Without the code, we cannot help you dude. Also you might wanna invest some time to learn English first or you will have a lot of trouble understanding what people are actually saying to you and explaining your problem to us also. – Vucko May 16 '16 at 16:42

3 Answers3

0

One of this posts could be helpful to you:

JSON Array Parse

Reading a Json Array in android

But i suggest you to use a parsing library which simplifies things a lot! There are many, one of them is GSON:

http://www.javacreed.com/simple-gson-example/

Community
  • 1
  • 1
urgas9
  • 806
  • 9
  • 22
0

I think it's json object, you can parse it with those code:

JSONObject jsonObject = new JSONObject("yourString");

and after

JSONArray jsonArray = jsonObject.getJSONArray("PositionList");

You can copy and paste your string to this page for checking : http://json.parser.online.fr/

Khoa Tran
  • 528
  • 6
  • 18
0

If you want to parse without using GSON library, do as follows

try{
            JSONObject jsonObject = new JSONObject(jsonData);
            boolean staus = jsonObject.getBoolean("Status");
            String message = jsonObject.getString("Message");
            JSONArray jsonPositionList = jsonObject.getJSONArray("PositionList");
            // parse json array
            for(int i = 0; i<jsonPositionList.length();i++){
                JSONObject object = (JSONObject) jsonPositionList.get(i);
                //parse object here
            }
            JSONObject loginUserInfo = jsonObject.getJSONObject("LoginUserInfo");
            //parse loginuserinfo here
            JSONObject loginDriverInfo = jsonObject.getJSONObject("LoginDriverInfo");
            //parse logindriverinfo
        }catch(JSONException e){
            e.printStackTrace();
        }
USKMobility
  • 5,721
  • 2
  • 27
  • 34