728x90
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<p id="demo"></p>
<script type="text/javascript">
let json = {
"quiz": {
"sport": {
"q1": {
"question": "Which one is correct team name in NBA?",
"options": [
"New York Bulls",
"Los Angeles Kings",
"Golden State Warriros",
"Huston Rocket"
],
"answer": "Huston Rocket"
}
},
"maths": {
"q1": {
"question": "5 + 7 = ?",
"options": [
"10",
"11",
"12",
"13"
],
"answer": "12"
},
"q2": {
"question": "12 - 8 = ?",
"options": [
"1",
"2",
"3",
"4"
],
"answer": "4"
}
}
}
};
function jsonTest() {
document.getElementById("demo").innerHTML
// = json.quiz["sport"].q1.question;
// = json.quiz["sport"].q1.options[2];
= json.quiz["maths"].q2.question;
}
jsonTest();
</script>
</body>
</html>
NBAjson.json
{
"quiz": {
"sport": {
"q1": {
"question": "Which one is correct team name in NBA?",
"options": [
"New York Bulls",
"Los Angeles Kings",
"Golden State Warriros",
"Huston Rocket"
],
"answer": "Huston Rocket"
}
},
"maths": {
"q1": {
"question": "5 + 7 = ?",
"options": [
"10",
"11",
"12",
"13"
],
"answer": "12"
},
"q2": {
"question": "12 - 8 = ?",
"options": [
"1",
"2",
"3",
"4"
],
"answer": "4"
}
}
}
}
'๐ ์๋ฐ ์๋ฒ ํ์ด์ง JSP > ๐ธ ์ ์ด์จ XML\JSON' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
4๏ธโฃ ์ ์ด์จ JSON - ์๊ธฐ๊ฐ ์ข์ํ๋์ฑ 5๊ฐ์ง ํ ์ด๋ธ ์๊ฐํ XML+ (0) | 2021.03.09 |
---|---|
2๏ธโฃ ์ ์ด์จ JSON - ๋ฐ์ดํฐ ๊ฐ์ ธ์ค๊ธฐ (0) | 2021.03.09 |
1๏ธโฃ ์ ์ด์จ JSON - ๊ธฐ๋ณธ 1 (0) | 2021.03.09 |
4๏ธโฃ XML - ์์ฉ (0) | 2021.03.09 |
3๏ธโฃ XML - ๋ฌธ์์ด ๋์ ๊ณผ ์ค์ XMLํ (0) | 2021.03.09 |
๋๊ธ