How to write JSON Object with space in name

Author: Zeeshan Arshad     1023     02/03/2013

Estimated reading time: 0 minutes, 23 seconds

Problem: So you are in trouble to write an object's value because the name of object has space in it. e.g. "This Is Name" You can access an object with space by using {}. 

 

Suppose you are using: echo $json_object->This Is Name; (obviously, it will display error) 

 

Solution: $json_object->{'This Is Name'};  // It will print out the value of object

 

 


Was this topic helpful?

Yes
No
Subscribe YouTube Channel

Zeeshan Arshad is a self-taught and multi-dimensional person with extraordinary track record of success with international clients and students.

Feel free to contact him for your project, training purpose or guidance.