https://github.com/deepakbhalla/springboot-public-api-consumer
This project demonstrates how to make a call to any external api using RestTemplate and get the json response ad marshal it in java object. For marshelling purpose, Gson library from Google has been used
https://github.com/deepakbhalla/springboot-public-api-consumer
api external-api gson java-8 json resttemplate springboot
Last synced: 4 months ago
JSON representation
This project demonstrates how to make a call to any external api using RestTemplate and get the json response ad marshal it in java object. For marshelling purpose, Gson library from Google has been used
- Host: GitHub
- URL: https://github.com/deepakbhalla/springboot-public-api-consumer
- Owner: deepakbhalla
- Created: 2021-02-04T13:48:07.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-02-08T07:29:47.000Z (about 5 years ago)
- Last Synced: 2025-01-18T17:49:22.060Z (over 1 year ago)
- Topics: api, external-api, gson, java-8, json, resttemplate, springboot
- Language: Java
- Homepage:
- Size: 14.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# springboot-public-api-consumer
This project demonstrates how to make a call to any external api using RestTemplate and get the json response ad marshal it in java object. For marshelling purpose, Gson library from Google has been used (Please refer https://github.com/google/gson for more details).
Below publically available api has been used for the test purpose only -
https://jsonplaceholder.typicode.com/users
which returns below json response -
```
[
{
"id": 1,
"name": "Leanne Graham",
"username": "Bret",
"email": "Sincere@april.biz",
"address": {
"street": "Kulas Light",
"suite": "Apt. 556",
"city": "Gwenborough",
"zipcode": "92998-3874",
"geo": {
"lat": "-37.3159",
"lng": "81.1496"
}
},
"phone": "1-770-736-8031 x56442",
"website": "hildegard.org",
"company": {
"name": "Romaguera-Crona",
"catchPhrase": "Multi-layered client-server neural-net",
"bs": "harness real-time e-markets"
}
},
.......
]
```
This project reads the response of this api, filters the data and returns below -
```
[
{
"lat": "-37.3159",
"lng": "81.1496",
"name": "Romaguera-Crona"
},
........
]
```