« Return to Blog

How to write JSON Object with space in name

Author: Zeeshan Arshad     1328     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