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

Windows 7 - STOP 0x0000007B (0xFFFFF880009A97E8 0xFFFFFFFFC0000034 0x0000000000 0x0000000000)

If you encounter STOP 0x0000007B (0xFFFFF880009A97E8 0xFFFFFFFFC0000034 0x0000000000 0x0000000000) blue screen of death. This is very like...