Skip to content

Instantly share code, notes, and snippets.

@nelsonenzo
Created October 12, 2011 05:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nelsonenzo/1280334 to your computer and use it in GitHub Desktop.
Save nelsonenzo/1280334 to your computer and use it in GitHub Desktop.
Javascript Notes and Helpers
Great Resource: http://www.json.org/js.html
// 99% of the time, you will want to be digest a json string from rails and read it into a javascript object.
response = JSON.parse(myJSONtext);
// then you can call the hash keys like they were methods
response.md5sum
response.file_name
// a reviver could be used as a pre-processor sort of, usually it will be left off.
JSON.parse(myJSONtext, reviver);
//conversely the to above, you can take a javascript object and convert it to valid JSON, with a sort of post processor.
JSON.stringify(myObject, replacer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment