Wednesday, August 31, 2011

JSON - Accessing object with hypen/dash

If you encounter json object that have - (hypen/dash) in the key, you will get a reference error if you access the object with dot manner. For example

{"cam-id":"1"}

Assuming the above object is call json_results, you will get an reference error if you

json_results.cam-id

You have to access the value by

json_results["cam-id"]

No comments:

Post a Comment

Facebook - Control privacy setting of liked page

By default, Facebook displayed your liked page to public. It is the user responsibility to adjust the privacy setting. And in my opinion, F...