如何解析Android中的JSON数据? [英] How to parse data from json in android?
本文介绍了如何解析Android中的JSON数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我称之为 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
这篇关于如何解析Android中的JSON数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文