How to decode a JSON String with several objects in PHP?

Posted by ilnur777 on Stack Overflow See other posts from Stack Overflow or by ilnur777
Published on 2010-04-01T11:54:19Z Indexed on 2010/04/01 12:13 UTC
Read the original article Hit count: 356

Filed under:
|
|

Hi, guys!

I know how to decode a JSON string with one object with your help from this example http://stackoverflow.com/questions/2543389/how-to-decode-a-json-string

But now I would like to improve decoding JSON string with several objects and I can't understand how to do it.

Here is an example:

{ "programmers": [
  { "firstName": "Brett", "lastName":"McLaughlin" },
  { "firstName": "Jason", "lastName":"Hunter" },
  { "firstName": "Elliotte", "lastName":"Harold" }
 ],
"authors": [
  { "firstName": "Isaac", "lastName": "Asimov" },
  { "firstName": "Tad", "lastName": "Williams" },
  { "firstName": "Frank", "lastName": "Peretti" }
 ],
"musicians": [
  { "firstName": "Eric", "lastName": "Clapton" },
  { "firstName": "Sergei", "lastName": "Rachmaninoff" }
 ]
}

How to decode this JSON, call data and display on the page from what object the informartion list is being read?

Thank you!

© Stack Overflow or respective owner

Related posts about php

Related posts about json-decode