JSON (JavaScript Object Notation)

  • http://json.org/
  • 인간이 읽고 쓰기 쉽게.
  • 기계가 파싱이나 생성이 쉽게.
  • 자바스크립트 문법에 일부 기반의 가벼운 데이타 교환 포맷

JSON 인코더와 디코더

JSON 자료구조는 Python 데이터 형으로 사상(매핑)됩니다

JSONDecoder

JSON Python
object dict
array list
string unicode
number (int) int, long
number (real) float
true True
false False
null None

JSONEncoder

Python JSON
dict object
list, tuple array
str, unicode string
int, long, float number
True true
False false
None null

Json Dumps , Json Loads

import json

# Create a data structure
data = [ { 'Hola':'Hello', 'Hoi':"Hello", 'noun':"hello" } ]

print(type(data), data)

json_encoded = json.dumps(data)

# print to screen
print(type(json_encoded), json_encoded)

decoded_data = json.loads(json_encoded)

# print to screen
print(type(decoded_data), decoded_data)

(TIP 1) 터미널에서 HTTPie 사용하기

results matching ""

    No results matching ""