Specific object retrieval from JSON

Hello, how do I retrieve a specific object from JSON from a specified number location?
For example in this JSON link: https://api.openbrewerydb.org/breweries?by_type=micro&per_page=50 How do I get the FIRST ‘name’ only?

1 Like

Hey @Abanoub_Gallah,

I’d recommend watching @simran’s tutorial on the WebAPI component as they explain how to do this.

This tutorial gives an overview of accessing elements by property name and by position in a list:

While this one give a more general intro to the WebAPI componet:

/
FInally, based on the API you are using, I’m guessing that you’re following @darren’s tutorials too, right?

1 Like

I tried this code block, but didn’t work, what should I do? I just want the first name to be displayed

1 Like

@domhnallohanlon I figured out a way to get the first ‘name’ but the problem is then switches to the second ‘name’ in the list how is that??

1 Like

@Abanoub_Gallah It looks like you are doing things out of order. You need to get the first element from the json list and then get the name property.

Here’s an example from my Brewbase API project cheatsheet:

3 Likes

Great! Thank you @darren for your reply. I found a way in which I click on the # in the list and choose ‘first’ this method gets only the first object from JSON.
Edit: I tried the method you replied, it also has the same problem. The thing is I use the same JSON link in two screens to get different attributes from the first element. One(screen) gets me the first element and the other(screen) gets me the second element.

I can’t tell if you are asking another question or saying your problem is solved? :thinking:

Thank you @darren I solved the problem.

2 Likes