简体   繁体   English

如何使用 gson 解析 Freebase 主题 api 响应

[英]how to parse Freebase topic api response with gson

is it possible to parse the json response returned by the Freebase experimental TOPIC Api with the google gson library?是否可以使用谷歌 gson 库解析 Freebase 实验性 TOPIC Api 返回的 json 响应? i have used gson to parse the json repsone from multiple freebase mqlread responses.我已经使用 gson 从多个 freebase mqlread 响应中解析 json repsone。 i am now stuck attempting to parse json messages like the response from this我现在被困在尝试解析 json 消息,例如来自此的响应

http://api.freebase.com/api/experimental/topic/basic?id=/en/sgt_peppers_lonely_hearts_club_band http://api.freebase.com/api/experimental/topic/basic?id=/en/sgt_peppers_lonely_hearts_club_band

or from this或从此

http://api.freebase.com/api/experimental/topic/basic?id=/en/please_please_me,/en/sgt_peppers_lonely_hearts_club_band http://api.freebase.com/api/experimental/topic/basic?id=/en/please_please_me,/en/sgt_peppers_lonely_hearts_club_band

or this或这个

http://api.freebase.com/api/experimental/topic/standard?id=/guid/9202a8c04000641f800000000de75560&domains=all http://api.freebase.com/api/experimental/topic/standard?id=/guid/9202a8c04000641f800000000de75560&domains=all

is it possible to parse all three repsones with one gson "code set"是否可以用一个 gson“代码集”解析所有三个响应

I have not tried to do this but there is no reason why it wouldn't work.我没有尝试过这样做,但没有理由它不起作用。 Are you getting any errors when you use it ?使用的时候有没有遇到什么错误? If you paste your code and errors I might be able to help you more.如果您粘贴代码和错误,我可能会为您提供更多帮助。

Take a look at the answer to this question:看看这个问题的答案:

Stuck on parsing a JSON response to a Java Object in Android 坚持在 Android 中解析对 Java 对象的 JSON 响应

The same approach should work for the Topic API.相同的方法应该适用于主题 API。

I gave up on GSON and switched to JACKSON it works perfectly for extracting the data of interest and ignoring everything else.我放弃了 GSON,转而使用 JACKSON,它非常适合提取感兴趣的数据并忽略其他所有内容。 thanks for all the time spent in responding to my question感谢您花时间回答我的问题

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

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