Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

11
  • 1
    Is that your real json? It is invalid. jsonlint.com Commented Apr 4, 2013 at 13:04
  • 2
    possible duplicate of how to assign variable value as variable name in a hash? Commented Apr 4, 2013 at 13:07
  • By storing your data as a JSON string, you incur the overhead of repeatedly parsing and stringifying your object every time you wish to change a property value. Why not just save it as an object, and stringify it when needed? Commented Apr 4, 2013 at 13:08
  • 1
    @SheikhHeera yes OK i failed to put the script on the end. Commented Apr 4, 2013 at 13:11
  • 1
    Ah I thought you want to find a solution for it, not (only) an explanation. The explanation is simple: Keys in object literals are interpreted literally, they are not resolved as identifiers. This is defined in the ECMAScript specification. Commented Apr 4, 2013 at 13:14