JSON은 null을 키값으로 가질 수 있을까?
JSON을 정의할 때 null을 키로 가질 수 있을지 궁금해서 jsonlint.com을 사용하여 테스트를 진행했습니다.
JSON Online Validator and Formatter - JSON Lint
Loading... About the JSONLint Editor JSONLint is a validator and reformatter for JSON, a lightweight data-interchange format. Copy and paste, directly type, or input a URL in the editor above and let JSONLint tidy and validate your messy JSON code. What Is
jsonlint.com
상기 사이트는 valid한 JSON 데이터인지 확인해 줍니다.
테스트용 데이터는 다음과 같습니다.
{
null:""
}
결과는
JSON의 key로 STRING이 있어야 하는데 NULL이 있어서 invalid json으로 결과값이 나왔습니다.
왜그럴까요?
https://www.json.org/json-ko.html
JSON
JSON (JavaScript Object Notation)은 경량의 DATA-교환 형식이다. 이 형식은 사람이 읽고 쓰기에 용이하며, 기계가 분석하고 생성함에도 용이하다. JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1
www.json.org
json은 name/value 형태의 쌍으로 collection 타입의 element로 ㄱ성되어 있고 이 element는 string으로 이루어져야 합니다. Value에는 null이 들어갈 수 있지만 name에는 반드시 string이 들어가야만 합니다