If objectmapper used in this cases, should I make a pojo?

|
vladyslav1357 2022-09-05 19:26:25
for username “admin”
Rainhvid 2022-09-05 20:28:35
#ASK

{
“Source”: {

“results”: [
{
“data_id”: “1”,
“data_String”: “string 1”
},
{
“data_id”: “2”,
“data_string”: “string 2”
},
{
“data_id”: “3”,
“data_string”: “string 3”
}
]
}
}

Hello guys. I really need help. I just fetch a json from api like this example. Right now I wanna extract the “results” and its value only. How can I do this? what library should I use? Should I make pojo as representation to that json object?

Siddharth Sharma 2022-09-05 21:07:52
Rainhvid 2022-09-05 20:28:35
#ASK

{
“Source”: {

“results”: [
{
“data_id”: “1”,
“data_String”: “string 1”
},
{
“data_id”: “2”,
“data_string”: “string 2”
},
{
“data_id”: “3”,
“data_string”: “string 3”
}
]
}
}

Hello guys. I really need help. I just fetch a json from api like this example. Right now I wanna extract the “results” and its value only. How can I do this? what library should I use? Should I make pojo as representation to that json object?

You can use JsonNode class…u can make object of that..store the api response in JsonNodd variable…and fetch the value from reposnnse…

Siddharth Sharma 2022-09-05 21:08:59
For ex JsonNode jsonNode = response(api response which you got)
JsonNode.get(“Source”).get(“results”) as text
Siddharth Sharma 2022-09-05 21:10:07
List<JsonNode>list = JsonNode.get(“Source”).get(“results”).asText
Siddharth Sharma 2022-09-05 21:10:43
Better you google about…Objectmapper..jsonNode class on google..you will get idea on that
Rainhvid 2022-09-05 21:11:10
Siddharth Sharma 2022-09-05 21:10:43
Better you google about…Objectmapper..jsonNode class on google..you will get idea on that

If objectmapper used in this cases, should I make a pojo?

Siddharth Sharma 2022-09-05 21:11:32
Rainhvid 2022-09-05 21:11:10
If objectmapper used in this cases, should I make a pojo?

If you just want to use the values…no need to make POJO

Siddharth Sharma 2022-09-05 21:11:44
You can jsonNode then
Siddharth Sharma 2022-09-05 21:12:08
Other wise…you can make POJO as well..if you’re confused
Rainhvid 2022-09-05 21:12:38
Siddharth Sharma 2022-09-05 21:11:32
If you just want to use the values…no need to make POJO

Btw this is a shipping API which I must save the cost into my db.

Rainhvid 2022-09-05 21:13:08
I’ve been through it for 4 days 😄
Siddharth Sharma 2022-09-05 21:14:11
Bro…JsonNode…ObjectMapper…POJO….there is nothing out of this in your problem scenario
Rainhvid 2022-09-05 21:15:24
Siddharth Sharma 2022-09-05 21:14:11
Bro…JsonNode…ObjectMapper…POJO….there is nothing out of this in your problem scenario

then is it enough to use jsonnode only?

Siddharth Sharma 2022-09-05 21:21:55
Yes
Rainhvid 2022-09-05 22:04:52
Siddharth Sharma 2022-09-05 21:21:55
Yes

Okay. Thank you Bro. 🙌

Bapu 2022-09-06 04:38:28
Yes
abhi 2022-09-06 06:42:30
Jdbc then spring jdbc then hibernate ,then some jpa /orm ,,so can anyone tell me why there are so many things to connect with db in java nd why we learn all of them
Uyr Ye Uu 2022-09-06 07:03:46
I know core Java can anyone tell me best way to master spring boot
Debiprasad Dash 2022-09-06 07:04:09
Uyr Ye Uu 2022-09-06 07:03:46
I know core Java can anyone tell me best way to master spring boot

Learn adv java

Uyr Ye Uu 2022-09-06 07:04:37
Are u talking about collection and threads
Uyr Ye Uu 2022-09-06 07:04:43
Lambda
Debiprasad Dash 2022-09-06 07:04:51
Uyr Ye Uu 2022-09-06 07:04:37
Are u talking about collection and threads

Jdbc, Servlet, jsp

Debiprasad Dash 2022-09-06 07:05:05
Uyr Ye Uu 2022-09-06 07:04:37
Are u talking about collection and threads

No

Debiprasad Dash 2022-09-06 07:05:18
Uyr Ye Uu 2022-09-06 07:04:37
Are u talking about collection and threads

These are core java concepts

Debiprasad Dash 2022-09-06 07:06:06
If you have time try to learn spring then spring boot
Debiprasad Dash 2022-09-06 07:07:02
Otherwise you can learn spring core and then start learning spring boot
Uyr Ye Uu 2022-09-06 07:27:44
Can you tell any cource
Uyr Ye Uu 2022-09-06 07:27:48
Well structured
Debiprasad Dash 2022-09-06 07:28:16
Uyr Ye Uu 2022-09-06 07:27:44
Can you tell any cource

Take from any institute

|