我想用gson解析facebook响应。 因为? 我在使用jsonObject和li(使用gson更快)转换响应时遇到一些性能问题。
出了什么问题?
这是我得到的答案:
{ "879252732136620_1951199524941930": {
"message": "Um casalzão desses, bicho.",
"full_picture": "external.xx.fbcdn.net/safe_image.php?d=AQCQ0oMPtxfdnPpY&url=https%3A%2F%2Fwww.fatosdesconhecidos.com.br%2Fwp-content%2Fuploads%2F2018%2F08%2FWinter-Soldier-and-Black-Widow-Sebastian-Stan-and-Scarlett-Johansson.jpg&_nc_hash=AQDO-9Cuik1pBMpu",
"created_time": "2018-08-13T00:15:00+0000",
"link": "bit.ly/2KDWEOo",
"permalink_url": "www.facebook.com/879252732136620/posts/1951199524941930/",
"type": "link",
"from": {
"name": "Fatos Nerd",
"id": "879252732136620"
},
"caption": "fatosdesconhecidos.com.br",
"name": "7 coisas que você não sabia sobre o relacionamento de Viúva Negra e Soldado Invernal",
"likes": {
"data": [
],
"summary": {
"total_count": 215,
"can_like": true,
"has_liked": false
}
},
"id": "879252732136620_1951199524941930" }, "124493634232128_2715192725162193": {
"message": "Parecer foi entregue ao TRF-4 goo.gl/VtL67a",
"full_picture": "scontent.xx.fbcdn.net/v/t39.2147-6/39117585_488969801570258_8939554907103428608_n.jpg?_nc_cat=1&oh=ab5d0d83da767acf3231053a87681d2b&oe=5C020E53",
"created_time": "2018-08-14T17:13:27+0000",
"link": "goo.gl/VtL67a",
"permalink_url": "www.facebook.com/124493634232128/posts/2715192725162193/",
"type": "link",
"from": {
"name": "UOL Notícias",
"id": "124493634232128"
},
"caption": "noticias.uol.com.br",
"name": "Lula \"simplesmente não é, e nem pode ser, candidato\", diz MPF",
"likes": {
"data": [
],
"summary": {
"total_count": 3732,
"can_like": true,
"has_liked": false
}
},
"id": "124493634232128_2715192725162193" } }
此处的问题是该字段以“ 879252732136620620_1951199524941930”开头,并且该值(即Facebook帖子的ID)因请求而异。因此,我不能简单地创建一个包含值“ 879252732136620620_1951199524941930”的gson对象,因为该值会因请求而异。
如果需要,可将其用于图形浏览器中的此响应选项:
? ids = 879252732136620_1951199524941930,124493634232128_2715192725162193,124493634232128_2715192725162193&fields = message,source,full_picture,created_time,link,permalink_url,type,object_id,来自,标题,名称,故事,likes.summary(true).fields(name)限制。 >