Skip to content
Advertisement

Trying to get property name and id of laravel payload

I have this JSON payload below and want to get names and ids from the payload. However, l cannot object names and ids from the payload.

Decode JSON

JavaScript

Api json payloads

JavaScript

Advertisement

Answer

Use json_decode to decode the json to an associative array, then access the elements of the array as you would any other assoc array.

It looks as though you can have one or more items in your collection, so you’ll want to use a loop to iterate over them.

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement