Skip to content

Instantly share code, notes, and snippets.

@uyu423
Created July 24, 2016 17:22
Show Gist options
  • Save uyu423/c2e638fe243e2f69fdb2125cbb9997f9 to your computer and use it in GitHub Desktop.
Save uyu423/c2e638fe243e2f69fdb2125cbb9997f9 to your computer and use it in GitHub Desktop.
<head>
<title>JSON Basic</title>
<meta charset="utf-8"/>
</head>
<body>
<script>
/* JSON Definition */
var json = '{ "NAME" : "Yongwoo", "AGE" : 25, "UNIVERSITY" : "Catholic Univ, of Korea", "MAJOR" : "Computer Science" }';
/* JSON Parse and Check */
var jsonObj = JSON.parse(json);
document.write("<br/><b>JSON Object</b><br/>");
for(var objVarName in jsonObj) {
document.write(objVarName, " : ", jsonObj[objVarName], "<br/>");
}
/* JON Object to JSON String */
var jsonStr = JSON.stringify(jsonObj);
document.write("<br/><b>JSON String Format :</b> ", jsonStr, "<br/>");
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment