Java - 嵌套内嵌套的Gson解析
我必须与 API 进行交互,并且响应格式(根据我所读到的)似乎结构很差。我发现 Google 网上论坛回复了一个有点类似的问题 这里,但我在实现 Response 类来处理 Gson.fromJson 时遇到问题。有没有我错过的例子?
{
"response":{
"reference": 1023,
"data":{
"user":{
"id":"210",
"firstName":"john",
"lastName":"smith",
"email":"[email protected]",
"phone":"",
"linkedid":{
"id":"238"
}
}
}
}
}
I have to interact with an API, and the response format (from what I've read) seems to be poorly structured. I've found a google groups reply to a somewhat similiar problem here, but I'm having trouble implementing a Response class to handle the Gson.fromJson. Is there an example I'm missing that's out there?
{
"response":{
"reference": 1023,
"data":{
"user":{
"id":"210",
"firstName":"john",
"lastName":"smith",
"email":"[email protected]",
"phone":"",
"linkedid":{
"id":"238"
}
}
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
JSON 对象
{}
可以由Map
或 Javabean 类表示。下面是一个使用 Javabean 的示例。使用方法如下:
The JSON objects
{}
can be represented by aMap<String, Object>
or a Javabean class. Here's an example which uses a Javabean.Use it as follows: