1

I have called webservice from android and got a response as below.....

Result from WebService =

11-30 13:21:16.304: DEBUG/Inside SOAP(512): JSON output {
11-30 13:21:16.304: DEBUG/Inside SOAP(512):   "_str": "anyType{string\u003dImplements and Equipments; string\u003dInsurance; string\u003dIrrigation and Water; }"
11-30 13:21:16.304: DEBUG/Inside SOAP(512): }

Now I want to parse these results and store in my SQLite database. How it can be done? I need your help please...

  • your service return invalid json String – ρяσѕρєя K Nov 29 '12 at 07:01
  • See my answer [here][2] And a Question [here][1] [1]: http://stackoverflow.com/questions/8381896/handle-server-response-in-android [2]: http://stackoverflow.com/questions/8033305/json-file-not-getting-downloaded-function-returns-null/8033471#8033471 It will help you.. – Shruti Nov 29 '12 at 07:05
  • I am getting this result from webservice.... anyType{string=Implements and Equipments; string=Insurance; string=Irrigation and Water; } How to parse this result? –  Nov 29 '12 at 07:11

1 Answers1

3

I'm assuming you want to get every string that follows an "=" and precedes a ";"

Here's a simple example:

// This is the string you want to parse
String searchableString = "string=first; string=second; string=third";

int indexOfEqualsSign = searchableString.indexOf("=");
int indexOfSemicolon = searchableString.indexOf(";");

while (indexOfEqualsSign >= 0) {
    String result = searchableString.substring(indexOfEqualsSign + 1, indexOfSemicolon);
    System.out.print(result);
    indexOfEqualsSign = searchableString.indexOf("=", indexOfSemicolon);
}

The output of the example looks like this:

first
second
third
David Kravitz
  • 96
  • 1
  • 4
  • @Imran khan sorry but i got the result is in the form as Result from WebService = FillAutoCompleteBudgetMasterItemsByMasterIdResponse{FillAutoCompleteBudgetMasterItemsByMasterIdResult=anyType{string=Implements and Equipments; string=Insurance; string=Irrigation and Water; }; } Now plz tell me how can I parse it using JSON –  Nov 29 '12 at 08:06