简体   繁体   English

用gson解析instagram json

[英]parse instagram json with gson

Trying to parse the following simple json response from instagram with gson but I get back "com.google.gson.stream.MalformedJsonException: Unterminated object at line 1 column 21": 尝试从gson解析instagram的以下简单json响应,但我返回“ com.google.gson.stream.MalformedJsonException:第1行第21列的未终止对象”:

{provider_url: http://instagram.com/, media_id: \"312873405259835666_223937937\", title:         \"#summer\", url: http://distilleryimage2.instagram.com/d4e0e83021cc11e2b74c22000a9f1427_7.jpg, author_name: \"kajsataskinen\", height: 612,width: 612,version: \"1.0\",author_url: http://instagram.com/, author_id: 223937937,type: \"photo\",provider_name: \"Instagram\"}

If I enclose the http links in double quotes it works fine. 如果我将http链接括在双引号中,则可以正常工作。 Any ideas? 有任何想法吗?

You can get an instagram json response here: http://instagram.com/api/v1/oembed/?url=http://instagr.am/p/RXjLRULekS/ 您可以在这里获取instagram json响应: http ://instagram.com/api/v1/oembed/?url= http : //instagr.am/p/RXjLRULekS/

Thanks 谢谢

Two things I can see. 我可以看到两件事。

  1. What you posted as the response is not actually what it responded with 您发布为回复的内容实际上并不是它回复的内容

  2. The string there is escaped, probably messing something up. 那里的绳子逃脱了,可能把东西弄乱了。

As for me the response is correctly escaped and "-ed: 对于我来说,响应可以正确地转义,然后用“ -ed:

{"provider_url":"http:\/\/instagram.com\/","media_id":

Apparently in the string you receive the escaping is missing.. How do you get it? 显然,您在字符串中收到的转义符丢失了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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