rest + spread(응용)3

다음과 같은 데이터가 있다고 해봅시다. 이런것은 나중에 API문서 등등 데이터를 받오는 것이다 라고 생각해주세요.

JSON 데이터 일반적으로 받아오기

// get.json
{
    "Americas": {
        "korea": [
            {
                "nation": "Seoul, South Korea",
                "name": "Mirae Asset Global Investments",
                "address": "13F, Tower1, 33, Jong-ro, Jongno-gu, Seoul, South Korea",
                "tel": "1577-1640",
                "link": "https://www.am.miraeasset.com/",
                "lat": 37.5619416,
                "lng": 127.00432739999997
            },
            {
                "nation": "Seoul, South Korea",
                "name": "Mirae Asset Daewoo",
                "address": "East Tower, Mirae Asset CENTER1 Bldg, 26, Eulji-ro 5-gil, Jung-gu, Seoul, South Korea",
                "tel": "1588-6800",
                "link": "https://english.miraeassetdaewoo.com/",
                "lat": 37.568293,
                "lng": 126.98470700000007
            },
            {
                "nation": "Seoul, South Korea",
                "name": "Mirae Asset Life Insurance",
                "address": "56, Gukjegeumyung-ro, Yeongdeungpo-gu, Seoul, South Korea",
                "tel": "1588-0220",
                "link": "http://life.miraeasset.com/eng_new/html/index.html",
                "lat": 37.5221883,
                "lng": 126.92971520000003
            }
        ],
        "japan": [
            {
                "nation": "Tokyo, Japan",
                "name": "Global X Japan",
                "address": "",
                "tel": "",
                "link": "https://globalxetfs.co.jp/en/",
                "lat": -6.2262724,
                "lng": 106.8085939
            },
            {
                "nation": "Tokyo, Japan",
                "name": "Global X Japan2",
                "address": "",
                "tel": "",
                "link": "https://globalxetfs.co.jp/en/",
                "lat": -6.2262724,
                "lng": 106.8085939
            }
        ]
    }
}

이제 데이터를 복사해서 가져왔으니, 원하는 데이터만 화면에 출력해봅시다.

JSON 데이터 화면에 출력하기

결과는 다음과 같습니다.

JSON 데이터 템플릿 만들어서 화면에(원하는 위치에) 출력하기

file-archive
1KB
JSON 데이터 가지고 놀기

Last updated