[Solved] Need Help Decoding a JSON Response

Ineed some help with decoding json responses from TicketMaster for an event search querry.

How do I display the event name, venue name, etc.? I am new at this and I am not an expert.

What I want my app to do is to list events for a particular classification name, city, state, and start date and display the response

with the event name, date, time, venue, city and state.

My api query is responding with the json however I don’t know how to decode and dipsplay the fileds that I want.

The json begins with _embedded, then events, then name, type, id, etc. (See attached powerpoint) If I display name, I get and undefined error.

Then I tried event, name and I get a blank screen no errors,

I am using the Thunkable X app sdk and the attached powerpoint shows how I am trying how to do it.

Thanks

Charles

Can you give me a URL you are using to get the JSON and I can take a look

You can PM me if it has a secret API.

@Charles_Casteel, The key here is understanding a little bit about the way that JSON text represents lists and objects. When you see something that begins with a '{' ( for example '{ _embedded: { events: ... ' ) that means that that the JSON text represents an object. When you see something that begins with a '[' ( for example '... [ { name: "Adam Sandler", ...' ) then that represents a list. It get a little more complicated, of course, because objects can contain lists within them and lists can contain objects within them.

In your case, we can see that the JSON returned by the Ticketmaster API call here represents an object with a property named "_embedded". The value of that "_embedded" property is an object which in turn contains a property called "events". The value of that "events" property is a list of objects representing a single event, and each of those objects has properties named "name", "type", "id", ... and interestingly "_embedded".

The value of that inner "embedded" property (which is contained in each object in the "events" list) is an object which has a "venues" property, whose value is a list. Each venue object in that list has a "name", "city" and "state" property (among others). The "city" property has as its value an object with a "name" property and the "state" property has as its value an object with a "name" property and a "stateCode" property.

Knowing all the above, here is a link to a shared example project that will display the name and city of the 2nd event. And here is a screenshot of the blocks from that project

Note that I have set the Ticketmaster URL property in the Web API property in the designer. That URL contains an API key and I’m not sure how long that key will be valid. If the app doesn’t work for you, you may need to replace the portion of that URL that contains the API key.

I hope this helps!

-Mark

3 Likes

Thank you for getting back to me. I was able to get the json fields for everything, i.e. name, venue, city and state for a particular event. GREAT!!!.

Now, I need help to list all of the events by name based on some filter.

I have attached my blocks. However, I get no results. Yes, the Ticketmaster api is retruning the json.

Thanks,

Charles

I have the same problem, How do you solve this issue?

Very late answer, but may be useful for others.
Many issues with your blocks:

  1. Your TMResponse is not yet a list. It is an object with 3 properties : “_embedded”, “_links” and “page”
  2. In the first “FOR” loop, you update TMevents with the current item “j”, and not inserting it as a new item in the TMevents
  3. The current item in the “FOR” loop, here named “j”, is not an index, but the complete item. In our case, it is a full event JSON object
  4. Same for the second “FOR” loop: You dig in TMevents to extract events’ names and you update TMname with the current “j” item

So the solution to your problem is the following:

Remark: The “IF” block inside the “FOR” loop is only to select unique values in the events’ names list, but you can omit it if you want all names, even duplicate ones.

Info: by the way, thank you for the ticketmaster API :wink:

1 Like