#advance JSON Reading

12 messages · Page 1 of 1 (latest)

gentle vault
#

I've been reading up on Jackson for a while to find a solution to this, but I've decided to finally just ask for help. I'm looking for a specific capability in reading a JSON.

My JSON source is one big array, with single objects stored at every index. Something like,

[
{ name: sarah, age: 12, eyes: "blue"},
{ name:ben, age: 23, eyes: "brown"}
]

I'd like to make a value search(in this example names) that returns the nested object with that give property value. The reason for is to have access to the other properties grouped with that one. In this case, I'd like to return the age and eyes color of a given person's name.

Is there something like this in Jackson or am I looking in the wrong place?

vast masonBOT
#

This post has been reserved for your question.

Hey @gentle vault! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

vast masonBOT
muted bay
#

I mean, Jackson can load your json into objects, then you can iterate over the objects until you find the name you want

gentle vault
#

I was hoping to avoid actually iterating though myself. I kinda assumed there was a better or already defined way of doing so.

muted bay
#

I think you're looking for JsonPath, but I'm not sure what do you figure you would gain from that

#

You're talking as if a loop was more complicated than integrating 3 different technologies

gentle vault
#

I found the Jsonpath, but I figured it didn't work in this case. Since the specific name is not a property key leading to a new object as its pair. Instead the name is just another property, and each object is just randomly placed in an array.

#

I also already have to work with Jackson, so I figured it was better to use it than iterating

muted bay
#

I don't think Jackson does that. You can probably beat it into building a Map rather than a List, but if you need to fight against the library then why use the library?

vast masonBOT
#

💤 Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping.
Warning: abusing this will result in moderative actions taken against you.