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...

3
  • your service return invalid json String Commented Nov 29, 2012 at 7:01
  • See my answer [here][2] And a Question [here][1] [1]: stackoverflow.com/questions/8381896/… [2]: stackoverflow.com/questions/8033305/… It will help you.. Commented Nov 29, 2012 at 7:05
  • I am getting this result from webservice.... anyType{string=Implements and Equipments; string=Insurance; string=Irrigation and Water; } How to parse this result? Commented Nov 29, 2012 at 7:11

1 Answer 1

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

1 Comment

@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

Your Answer

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