-1

I am getting response in this way:

{
    agentCode: 9911223344,
    transId: 337450,
    resultCode: 0,
    resultDesc: Transaction Successful,
    dealList = [1, EST1], [2, EST2], [3, EST3]
}

I have to fetch data under dealList ,kindly tell me how can i do that.

K Neeraj Lal
  • 6,700
  • 3
  • 22
  • 33
Niraj Kumar
  • 49
  • 1
  • 8

2 Answers2

0

You have invalid formatted json message.
First of all you cannot use [ ] because according json specification is assumes that this will be an array. You have to change these entries to the object ones { }. You have to manually parse it, BTW as a plain string, or make json message valid and use libraries - GSON or Jackson

Here is valid json that I would use in your case

{
    "agentCode": 9911223344,
    "transId": 337450,
    "resultCode": 0,
    "resultDesc": "Transaction Successful",
    "dealList": [{
        "id": 1,
        "value": "EST1"
    }, {
        "id": 2,
        "value": "EST2"
    }, {
        "id": 3,
        "value": "EST3"
    }]
}
CROSP
  • 4,298
  • 4
  • 36
  • 85
0

You have an invalid json string.

You can check if it valid or not by this page http://jsonlint.com/

For json parser, you can simple parse json use default functions of Android SDK

http://www.tutorialspoint.com/android/android_json_parser.htm

dangbk
  • 1