
JSON(javascript Object Notation)라는 의미의 축약어로 데이터를 저장하거나 전송할 때 많이 사용 되는경량의 DATA 교환 형식을 의미한다.
Javascript에서 객체를 만들 때 사용하는 표현식.사람과 기계 모두 이해하기 쉬우며 용량이 작아서, 최근에는 XML을 대체해서 데이터 전송에 사용한다.포맷일 뿐이며 어떠한 통신 방법도, 프로그래밍 문법도 아닌 단순히 데이터를 표시하는 표현 방법.서버와 클라이언트 간의 교류에서 일반적으로 많이 사용 된다.개인적으로 key-value 형식으로 데이터를 저장하고 출력할 수 있기에 간편한 느낌.
XML고, 이후 가장 많이 사용 되는 것이 아마도 JSON일 것이다.중괄호({}) 같은 형식으로 하고, 값을 ','로 나열하기에 그 표현이 간단하다.{
"employees": [
{
"name": "Surim",
"lastName": "Son"
},
{
"name": "Someone",
"lastName": "Huh"
},
{
"name": "Someone else",
"lastName": "Kim"
}
]
}
JSON 형식은 Javascript 객체와 마찬가지로 key / value가 존재할 수 있으며 key값이나 문자열은 항상 " "를 이용하여 표기 해야 한다.
{
"firstName": "Kwon",
"lastName": "YoungJae",
"email": "kyoje11@gmail.com"
}
{
"firstName": "Kwon",
"lastName": "YoungJae",
"email": "kyoje11@gmail.com",
"hobby": ["puzzles","swimming"]
}
AJAX 는 단순히 데이터 만이 아니라 JavaScript 그 자체도 전달할 수 있다. 이 말은 JSON데이터라고 해서 받았는데 단순 데이터가 아니라 JavaScript가 될 수도 있고, 그게 실행 될 수 있다는 것이다. (데이터인 줄 알고 받았는데 악성 스크립트가 될 수 있다.)
위와 같은 이유로 받은 내용에서 순수하게 데이터만 추출하기 위한 JSON 관련 라이브러리를 따로 사용하기도 한다.
JSON으로 가져올 수 있는 데이터는 해당 Javascript가 Load된 서버의 데이터에 한정된다.
예를 들어, http://kwz.kr/json.js에서 불러올 수 있는 데이터는 kwz.kr 서버에 존재하는 것만 가능하다.
(구글 데이터를 불러온다거나 네이버 데이터를 불러온다거나 할 수 없다.)
JSON은 단순히 데이터 Format일 뿐이며 그 데이터를 불러오기 위해선 XMLHttpRequest()라는 Javascript 함수를 사용해야 하는데 이 함수가 동일 서버에 대한 것만 지원하기 때문이다. (JSONP 또는 프락시 역할을 하는 server쪽 Script 파일로 가능 하게도 할 수 있다.)
var jsonText = '{ "name": "Someone else", "lastName": "Kim" }'; // JSON 형식의 문자열
var realObject = JSON.parse(jsonText);
var jsonText2 = JSON.stringify(realObject);
console.log(realObject);
console.log(jsonText2);
JSON 형식의 텍스트를 자바스크립트 객체로 변환한다.자바스크립트 객체를 JSON 텍스트로 변환한다.Java)JSONObject jsonMetaObj = new JSONObject();
ObjectMapper mapper = new ObjectMapper();
String realPath = request.getRealPath("/");
jsonMetaObj = mapper.readValue(new File(realPath + "/preregister/metaData.json"), new JSONObject().getClass());
JSONObject metaData = JSONObject.fromObject(jsonMetaObj.get(gameCode));
metaData = JSONObject.fromObject(metaData.get(languageCode));
Java){
"131": {
"ko" : {
"metaUrl": "http://potc.joycity.com/ko"
},
"ja" : {
"metaUrl": "http://potc.joycity.com/ja"
}
},
"133": {
"ko" : {
"metaUrl": "http://pregbtw.joycity.com/ko"
},
"ja" : {
"metaUrl": "http://pregbtw.joycity.com/ja"
}
}
}xManager https://xmanagerapp.net/ is an exceptional software tool, effectively bridging the divide between various music applications. Healthcare Summit 2024 https://healthai.institute/ enhances user convenience with its updated data.
The first time I tried playing blackjack online, I was skeptical about how engaging it would be compared to a live casino. To my surprise, I found that online blackjack had its own kind of thrill. Without the pressure of a live dealer https://tortugacasino-fr1.com/ or other players watching, I was able to focus completely on refining my strategy. It gave me the perfect environment to practice card counting and other techniques without feeling rushed. At first, I was losing small amounts, but gradually I started to see improvement as I fine-tuned my approach and stuck to a disciplined betting strategy.
Box64droid https://box64droid.com/ stands out as an exceptional software tool, effectively bridging the divide between various computing architectures. NetherSX2 https://nethersx2.com/ enhances user convenience with its updated frontend.