简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM