๐Ÿ“œ JSON์ด๋ž€ ๋ฌด์—‡์ผ๊นŒ?

๊ฐœ๋ฐœVelogยท2021๋…„ 6์›” 13์ผ
1

C#

๋ชฉ๋ก ๋ณด๊ธฐ
8/9
post-thumbnail

  • ๋„คํŠธ์›Œํฌ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋ฐ์ดํ„ฐ ํ†ต์‹ ์€ byteํ˜•ํƒœ๋กœ ์ „๋‹ฌ์„ ํ•ด์ฃผ๋Š”๋ฐ JSON๊ณผ XML์€ ๊ณต์‹ ํฌ๋งท์ด๋ฏ€๋กœ ๋ฐ์ดํ„ฐ ํ†ต์‹ ์ด ๊ฐ€๋Šฅ.
  • ๋ฐ์ดํ„ฐ๋ฅผ ๋ณด๋‹ค ์‰ฝ๊ฒŒ ์ €์žฅ์„ ํ•˜๊ณ  ์ „๋‹ฌํ•  ๋ชฉ์ ์œผ๋กœ ๋งŒ๋“ค์–ด์ง„ JSON๊ณผ XML์— ๋Œ€ํ•ด ๊ฐ„๋‹จํ•˜๊ฒŒ
    ์ •๋ฆฌํ•ด ๋ณผ ์˜ˆ์ •.

๋จผ์ € JSON์— ๋Œ€ํ•ด ์•Œ์•„๋ณด์ž.
XML ๊ด€๋ จ ๊ธ€์€ <- ์—ฌ๊ธฐ๋กœ !!!

๐Ÿ“œ JSON์ด๋ž€?

  • JSON๋Š” (JavaScript Object Notation)์˜ ์•ฝ์ž๋กœ
    ์‚ฌ๋žŒ์ด ์ฝ์„ ์ˆ˜ ์žˆ๋Š” ํ…์ŠคํŠธ ๊ธฐ๋ฐ˜์˜ ๋ฐ์ดํ„ฐ ๊ตํ™˜ ํ‘œ์ค€.
  • javascript์—์„œ ๊ฐ์ฒด๋ฅผ ๋งŒ๋“ค ๋•Œ ์‚ฌ์šฉํ•˜๋Š” ํ‘œํ˜„์‹.
  • ์‚ฌ๋žŒ๊ณผ ๊ธฐ๊ณ„ ๋ชจ๋‘ ์ดํ•ดํ•˜๊ธฐ ์‰ฝ๊ณ  ์šฉ๋Ÿ‰์ด ์ž‘์•„์„œ ์ตœ๊ทผ์—๋Š” JSON์ด XML์„ ๋Œ€์ฒดํ•˜์—ฌ
    ๋ฐ์ดํ„ฐ ์ „์†ก ๋“ฑ์— ๋งŽ์ด ์‚ฌ์šฉ.
  • json๋Š” ๋ฐ์ดํ„ฐ ํฌ๋งท์ผ ๋ฟ์ด๊ณ  ๋‹จ์ˆœํžˆ ๋ฐ์ดํ„ฐ๋ฅผ ํ‘œ์‹œํ•˜๋Š” ํ‘œํ˜„ ๋ฐฉ๋ฒ•

๐Ÿ“œ JSON ํŠน์ง•

  • ํŠน์ • ์–ธ์–ด์— ์ข…์†์ด ๋˜์ง€ ์•Š๊ณ  ๋Œ€๋ถ€๋ถ„์˜ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์—์„œ JSON์„ ํ•ธ๋“ค๋งํ•  ์ˆ˜ ์žˆ๋„๋ก ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์ œ๊ณต.
  • ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ๊ฐ์ฒด ํ‘œ๊ธฐ๋ฒ•์„ ๋”ฐ๋ฅด์ง€๋งŒ ๋‹จ์ˆœํ•œ ํ…์ŠคํŠธ ํ˜•์‹์ผ ๋ฟ.

๐Ÿ“œ JSON ์žฅ์ 

  • XML๋ณด๋‹ค ์ตœ์†Œํ•œ์˜ ์šฉ๋Ÿ‰์œผ๋กœ ๋ฐ์ดํ„ฐ ์ „์†ก์ด ๊ฐ€๋Šฅ.
  • XML๋ณด๋‹ค ๊ตฌ์กฐ ์ •์˜์˜ ์šฉ์ด์„ฑ๊ณผ ๊ฐ€๋…์„ฑ์ด ๋›ฐ์–ด๋‚จ.

๐Ÿ“œ JSON ๋‹จ์ 

  • XML์— ๋น„ํ•ด ๋ฌธ๋ฒ• ์˜ค๋ฅ˜์— ์ทจ์•ฝ.
  • XML๋Š” ์‚ฌ์šฉ์ฒ˜๋งˆ๋‹ค ์š”๊ตฌ๋˜๋Š” ๊ตฌ์กฐ์™€ ํ˜•ํƒœ๋ฅผ ์ž˜ ๊ฐ–์ท„๋Š”์ง€ ์Šคํ‚ค๋งˆ๋ฅผ ์ด์šฉํ•ด ๊ฒ€์ฆ ๊ฐ€๋Šฅํ•œ๋ฐ
    JSON๋Š” ์ด๋Ÿฐ ๊ธฐ๋Šฅ X.
  • JSON๋Š” ์ฃผ์„ ๋ถˆ๊ฐ€.

๐Ÿ“œ JSON ๊ตฌ์กฐ

  • JSON ๋ฐ์ดํ„ฐ๋Š” ์ด๋ฆ„๊ณผ ๊ฐ’์˜ ์Œ.
  • JSON ๋ฐ์ดํ„ฐ๋Š” ์‰ผํ‘œ(,)๋กœ ๋‚˜์—ด.
  • ๊ฐ์ฒด(object)๋Š” ์ค‘๊ด„ํ˜ธ({})๋กœ ๋‘˜๋Ÿฌ์Œ“์•„ ํ‘œํ˜„.
  • ๋ฐฐ์—ด(array)๋Š” ๋Œ€๊ด„ํ˜ธ([])๋กœ ๋‘˜๋Ÿฌ์Œ“์•„ ํ‘œํ˜„.
{
  "squadName": "Super hero squad",
  "homeTown": "Metro City",
  "formed": 2016,
  "secretBase": "Super tower",
  "active": true,
  "members": [
    {
      "name": "Molecule Man",
      "age": 29,
      "secretIdentity": "Dan Jukes",
      "powers": [
        "Radiation resistance",
        "Turning tiny",
        "Radiation blast"
      ]
    },
    {
      "name": "Madame Uppercut",
      "age": 39,
      "secretIdentity": "Jane Wilson",
      "powers": [
        "Million tonne punch",
        "Damage resistance",
        "Superhuman reflexes"
      ]
    },
    {
      "name": "Eternal Flame",
      "age": 1000000,
      "secretIdentity": "Unknown",
      "powers": [
        "Immortality",
        "Heat Immunity",
        "Inferno",
        "Teleportation",
        "Interdimensional travel"
      ]
    }
  ]
}
์ถœ์ฒ˜ ๋ฐ ์ฐธ์กฐ :

http://tcpschool.com/json/json_basic_structure

profile
์•ˆ๋…•ํ•˜์„ธ์š”. ๋ฐ์ดํ„ฐ์™€ ๋™๊ณ ๋™๋ฝ ์ค‘์ธ ๊ฐœ๋ฐœ์ž ์ž…๋‹ˆ๋‹ค.

0๊ฐœ์˜ ๋Œ“๊ธ€