错误解析JSON
,当我刚刚学会Android JSON Parsing Tutorial错误解析JSON
我下载的源代码,并成功地与默认的JSON数据从here
运行它,然后我试图复制他的JSON data为localhost和我的网站
我改变了这种代码
> private static String url = "http://api.androidhive.info/contacts/";
到
> private static String url = "http://yumugee.com/data.json";
和
> 02-04 19:38:48.343: E/JSON Parser(1233): Error parsing data
> org.json.JSONException: Value <!DOCTYPE of type java.lang.String
> cannot be converted to JSONObject
我又改成了
> private static String url = "http://192.168.1.100/data.json/";
,我得到了一个错误太
> 02-04 19:30:10.332: E/JSON Parser(1201): Error parsing data
> org.json.JSONException: Value <?xml of type java.lang.String cannot be
> converted to JSONObject
有谁知道我从日志猫错误如何解决这个问题?
sry为我的英语不好,希望你明白我的要求。 THX
{
"contacts": [
{
"id": "c200",
"name": "Ravi Tamada",
"email": "[email protected]",
"address": "xx-xx-xxxx,x - street, x - country",
"gender" : "male",
"phone": {
"mobile": "+91 0000000000",
"home": "00 000000",
"office": "00 000000"
}
},
{
"id": "c201",
"name": "Johnny Depp",
"email": "[email protected]",
"address": "xx-xx-xxxx,x - street, x - country",
"gender" : "male",
"phone": {
"mobile": "+91 0000000000",
"home": "00 000000",
"office": "00 000000"
}
},
{
"id": "c202",
"name": "Leonardo Dicaprio",
"email": "[email protected]",
"address": "xx-xx-xxxx,x - street, x - country",
"gender" : "male",
"phone": {
"mobile": "+91 0000000000",
"home": "00 000000",
"office": "00 000000"
}
},
{
"id": "c203",
"name": "John Wayne",
"email": "[email protected]",
"address": "xx-xx-xxxx,x - street, x - country",
"gender" : "male",
"phone": {
"mobile": "+91 0000000000",
"home": "00 000000",
"office": "00 000000"
}
},
{
"id": "c204",
"name": "Angelina Jolie",
"email": "[email protected]",
"address": "xx-xx-xxxx,x - street, x - country",
"gender" : "female",
"phone": {
"mobile": "+91 0000000000",
"home": "00 000000",
"office": "00 000000"
}
},
{
"id": "c205",
"name": "Dido",
"email": "[email protected]",
"address": "xx-xx-xxxx,x - street, x - country",
"gender" : "female",
"phone": {
"mobile": "+91 0000000000",
"home": "00 000000",
"office": "00 000000"
}
},
{
"id": "c206",
"name": "Adele",
"email": "[email protected]",
"address": "xx-xx-xxxx,x - street, x - country",
"gender" : "female",
"phone": {
"mobile": "+91 0000000000",
"home": "00 000000",
"office": "00 000000"
}
},
{
"id": "c207",
"name": "Hugh Jackman",
"email": "[email protected]",
"address": "xx-xx-xxxx,x - street, x - country",
"gender" : "male",
"phone": {
"mobile": "+91 0000000000",
"home": "00 000000",
"office": "00 000000"
}
},
{
"id": "c208",
"name": "Will Smith",
"email": "[email protected]",
"address": "xx-xx-xxxx,x - street, x - country",
"gender" : "male",
"phone": {
"mobile": "+91 0000000000",
"home": "00 000000",
"office": "00 000000"
}
},
{
"id": "c209",
"name": "Clint Eastwood",
"email": "[email protected]",
"address": "xx-xx-xxxx,x - street, x - country",
"gender" : "male",
"phone": {
"mobile": "+91 0000000000",
"home": "00 000000",
"office": "00 000000"
}
},
{
"id": "c2010",
"name": "Barack Obama",
"email": "[email protected]",
"address": "xx-xx-xxxx,x - street, x - country",
"gender" : "male",
"phone": {
"mobile": "+91 0000000000",
"home": "00 000000",
"office": "00 000000"
}
},
{
"id": "c2011",
"name": "Kate Winslet",
"email": "[email protected]",
"address": "xx-xx-xxxx,x - street, x - country",
"gender" : "female",
"phone": {
"mobile": "+91 0000000000",
"home": "00 000000",
"office": "00 000000"
}
},
{
"id": "c2012",
"name": "Eminem",
"email": "[email protected]",
"address": "xx-xx-xxxx,x - street, x - country",
"gender" : "male",
"phone": {
"mobile": "+91 0000000000",
"home": "00 000000",
"office": "00 000000"
}
}
]
}
此错误消息似乎像结果数据不是JSON格式。它只是xml字符串。
你能在这里显示你的结果数据吗?
没有它的json数据...看到我的答案.... – 2012-02-04 15:03:13
程序成功运行与默认源http://api.androidhive.info/联系人/ 但是,当我试图用我的文件 (从http://api.androidhive.info/contacts/复制) 我之前得到一个错误 – yumugee 2012-02-04 15:04:41
对不起,我cannt访问该地址。 – shenhengbin 2012-02-04 15:04:42
如果你想从本地主机运行该代码,你应该编写localhost地址,如下面的http:// 10.0.2.2
/android_api/data.php,其中android_api是你的wamp www文件夹内的文件夹。而不是yoursite.in写入10.0.2.2或您的机器的IP地址。尝试这个。
看来你没有得到任何回应。从浏览器访问网址,看到你得到任何答复或不。 – kosa 2012-02-04 14:38:18
看到我的回答下面它的工作罚款在java没有prblm .... – 2012-02-04 15:01:51