๋ณธ๋ฌธ์œผ๋กœ ๊ฑด๋„ˆ๋›ฐ๊ธฐ

200320

ยท ์•ฝ 2๋ถ„

Ajax#

Ajax(Asynchronous JavaScript and XML)

์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ด์šฉํ•ด์„œ ๋น„๋™๊ธฐ์ ์œผ๋กœ ์„œ๋ฒ„์™€ ๋ธŒ๋ผ์šฐ์ €๊ฐ€ ๋ฐ์ดํ„ฐ๋ฅผ ์ฃผ๊ณ  ๋ฐ›๋Š” ๋ฐฉ์‹์„์˜๋ฏธ


JSON#

JSON

JSON(JavaScript Object Notation)

JavaScript์—์„œ ๊ฐ์ฒด๋ฅผ ๋งŒ๋“ค ๋•Œ ์‚ฌ์šฉํ•˜๋Š” ํ‘œํ˜„์‹์„ ์˜๋ฏธ

์ด ํ‘œํ˜„์‹์€ ์‚ฌ๋žŒ๋„ ์ดํ•ดํ•˜๊ธฐ ์‰ฝ๊ณ  ๊ธฐ๊ณ„๋„ ์ดํ•ดํ•˜๊ธฐ ์‰ฌ์šฐ๋ฉด์„œ ๋ฐ์ดํ„ฐ์˜ ์šฉ๋Ÿ‰์ด ์ž‘๋‹ค. ์ด๋Ÿฐ ์ด์œ ๋กœ ์ตœ๊ทผ์—๋Š” JSON์ด XML์„ ๋Œ€์ฒดํ•ด์„œ ์„ค์ •์˜ ์ €์žฅ์ด๋‚˜ ๋ฐ์ดํ„ฐ๋ฅผ ์ „์†ก๋“ฑ์— ๋งŽ์ด ์‚ฌ์šฉ๋œ๋‹ค.


{    "coord": {"lon": 139, "lat": 35},    "weather": [        {            "id": 800,            "main": "Clear",            "description": "clear sky",            "icon": "01n"        }    ],    "base": "stations",    "main": {        "temp": 281.52,        "feels_like": 278.99,        "temp_min": 280.15,        "temp_max": 283.71,        "pressure": 1016,        "humidity": 93    },    "wind": {        "speed": 0.47,        "deg": 107.538    },    "clouds": {        "all": 2    },    "dt": 1560350192,    "sys": {        "type": 3,        "id": 2019346,        "message": 0.0065,        "country": "JP",        "sunrise": 1560281377,        "sunset": 1560333478    },    "timezone": 32400,    "id": 1851632,    "name": "Shuzenji",    "cod": 200}

JSON API#

JSON.parse()#

์ธ์ž๋กœ ์ „๋‹ฌ๋œ ๋ฌธ์ž์—ด์„ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ๋ฐ์ดํ„ฐ๋กœ ๋ณ€ํ™˜ํ•œ๋‹ค.

JSON.stringify()#

์ธ์ž๋กœ ์ „๋‹ฌ๋œ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ์˜ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฌธ์ž์—ด๋กœ ๋ณ€ํ™˜ํ•œ๋‹ค.