JSON

Published by onesixx on

https://pynative.com/python-json-exercise/

Json 표준에는 겹따옴표가 표준이고 홑따옴표가 비표준이라는 것

vsCode에서 JSON파일

vscode ~ new file ~ select language : json

~ Shift+Option(alt)+ F ==> json 예쁘게 보기

dictionary -> json 문자열 :: json.dump()

http://b1ix.net/402

json.dump() vs. json.dumps()

dump() 함수: Python객체를 JSON “파일”에 저장하기

dumps() 함수: Python객체를 JSON “문자열”로 변환

https://www.delftstack.com/ko/howto/python-pandas/json-to-pandas-dataframe/

더블쿼테이션이 표준

JSON
app/data/mobi-ex1.json
JSON
app/data/mobi-ex1-single_quote.txt
Python

json문자열 -> dictionary :: json.load()

json.load() vs. json.loads()

load() 함수: JSON “파일”을 Python객체로 불러오기

loads() 함수: JSON “문자열”을 Python객체로 변환

json.load()

To parse JSON from URL or file

TextIOWrapper

Python

fp: file pointer used to read a file,

json.loads()

For parse string with JSON content
into (python)Dictionary

str, bytes or bytearray

Python

file pointer used to read a text file,

Python JSON parsing using load and loads
https://pynative.com/python-json-load-and-loads-to-parse-json/

에러

AttributeError: ‘str’ object has no attribute ‘loads’

=> json.load()와 json.loads()를 구별못했거나, json이름을 변수로 사용한 경우

json 예제

JSON
Python

read inline json

Python

read json Files

JSON
Python

JSON parse

Python
JSON
./text.json

Error

JSONDecodeError: Expecting property name enclosed in double quotes: line 2 column 1 (char 2)

Categories: Python Basic

onesixx

Blog Owner

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x