Skip to content Skip to sidebar Skip to footer

How To Parse Data From Json In Android?

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

Solution 1:

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

Post a Comment for "How To Parse Data From Json In Android?"