Created
October 12, 2011 05:00
-
-
Save nelsonenzo/1280334 to your computer and use it in GitHub Desktop.
Javascript Notes and Helpers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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