Menu
Coddy logo textTech

JSON - API Response

Coddy의 Python으로 배우는 API 코스 레슨 — 10개 중 3번째.

API 응답은 종종 JSON이라는 형식으로 제공됩니다. 

JSONJavaScript Object Notation의 약자입니다. JSON은 파이썬의 기본 딕셔너리(dictionary) 데이터 타입과 유사합니다.

이러한 API 응답은 다음과 같이 보입니다:

{
	"errors": [
		{
			"status": "422",
			"source": {
				"pointer": "/data/attributes/firstName"
			},
			"title": "Invalid Attribute",
			"detail": "First name must contain at least two characters." 
    	}
    ] 
}

파이썬의 딕셔너리와 마찬가지로 JSON을 조작할 수 있습니다. 

challenge icon

챌린지

쉬움

아래 JSON 코드가 주어졌을 때, "errors" 키의 값을 print해 보세요. 
이를 위해서는 dictionaries가 어떻게 작동하는지에 대해 더 잘 이해하고 있어야 합니다. 

이 내용은 Python 기초 과정의 dictionaries 섹션에서 다룹니다.

직접 해보기

json = {
    "errors": [
        {
            "status": "422",
            "source": {
                "pointer": "/data/attributes/firstName"
            },
            "title": "Invalid Attribute",
            "detail": "First name must contain at least two characters."
        }
    ]
}

### Write Your Code Below This Line

Python으로 배우는 API의 모든 레슨