How to write JSON Object with space in name

Author: Zeeshan Arshad     1442     02/03/2013

Estimated reading time: 0 minutes, 23 seconds

Zeeshan Arshad - Lifestyle Blog

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

 

 

« Return to Blog