-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"
    }
}
1
  • 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. Commented May 16, 2016 at 16:42

3 Answers 3

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();
        }
Sign up to request clarification or add additional context in comments.

Comments

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/

Comments

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/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.