gpt4 book ai didi

java - 如何生成JSON响应的POJO类

转载 作者:行者123 更新时间:2023-12-01 16:19:31 25 4
gpt4 key购买 nike

大家好,我正在使用 PixaBay API 在我的应用程序中获取图像。我正在使用 url https://pixabay.com/api/?key=My-KEY。我收到类似的响应下面我如何从下面的响应中创建 POJO 类。

 {
"total":1261984,
"totalHits":500,
"hits":[
{
"id":5265194,
"pageURL":"https://pixabay.com/photos/lein-staudenlein-blue-flax-flower-5265194/",
"type":"photo",
"tags":"lein, staudenlein, blue flax",
"previewURL":"https://cdn.pixabay.com/photo/2020/06/06/04/20/lein-5265194_150.jpg",
"previewWidth":150,
"previewHeight":100,
"webformatURL":"https://pixabay.com/get/53e2d3464b5ba814f1dc8460962931771d3cdae5504c704c7c2e73d5964fc05e_640.jpg",
"webformatWidth":640,
"webformatHeight":427,
"largeImageURL":"https://pixabay.com/get/53e2d3464b5ba814f6da8c7dda7936781c37dde153526c4870267adc964cc75dbe_1280.jpg",
"imageWidth":6240,
"imageHeight":4160,
"imageSize":5132057,
"views":9106,
"downloads":8127,
"favorites":25,
"likes":77,
"comments":68,
"user_id":10327513,
"user":"NickyPe",
"userImageURL":"https://cdn.pixabay.com/user/2020/06/08/09-39-40-606_250x250.jpg"
},
{
"id":5255326,
"pageURL":"https://pixabay.com/photos/landscape-fantasy-sky-clouds-5255326/",
"type":"photo",
"tags":"landscape, fantasy, sky",
"previewURL":"https://cdn.pixabay.com/photo/2020/06/03/15/20/landscape-5255326_150.jpg",
"previewWidth":150,
"previewHeight":100,
"webformatURL":"https://pixabay.com/get/53e2d0464950aa14f1dc8460962931771d3cdae5504c704c7c2e73d5964fc05e_640.jpg",
"webformatWidth":640,
"webformatHeight":427,
"largeImageURL":"https://pixabay.com/get/53e2d0464950aa14f6da8c7dda7936781c37dde153526c4870267adc964cc75dbe_1280.jpg",
"imageWidth":7087,
"imageHeight":4724,
"imageSize":3912235,
"views":29283,
"downloads":24114,
"favorites":80,
"likes":174,
"comments":108,
"user_id":3764790,
"user":"enriquelopezgarre",
"userImageURL":"https://cdn.pixabay.com/user/2020/06/03/11-05-03-625_250x250.jpg"
}
]
}

在这里,我只想从上面的响应中获取预览 URL。我如何制作相同的 POJO 类。请有人帮助我,任何帮助将不胜感激。

谢谢

最佳答案

您可以使用该网站生成pojo类。这是链接http://www.jsonschema2pojo.org/

关于java - 如何生成JSON响应的POJO类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62310092/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com