如何解析Android中的JSON数据?数据、Android、JSON

2023-09-08 00:29:17 作者:一曲落花终情殇

我称之为 Web服务从Android和得到答复如下......

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

这是WebService的结果=

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): }

现在我要分析这些结果,并存储在我的的SQLite 数据库。如何可以做到?我需要你的帮助,请...

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

推荐答案

我假设你希望让每一个跟随一个=和$ P $字符串pcedes一个;

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