Json 의 content type

LONGNEW·2020년 12월 24일
0

StackOverFlaw

목록 보기
2/16

https://stackoverflow.com/questions/477816/what-is-the-correct-json-content-type

Q. What is the correct JSON content type?
Q. Json content 의 type은 무엇인가요??
I've been messing around with JSON for some time, just pushing it out as text and it hasn't hurt anybody (that I know of), but I'd like to start doing things properly.
JSON을 가지고 씹고 뜯고 맛보고 몇번 해봤는데요. text/* 형식으로 보내도 에러가 발생하거나 하진 않았지만, 정확한 정의를 알고 싶습니다.
I have seen so many purported "standards" for the JSON content type:
JSON content type의 "standard"라고 불려지는 것들:

application/json
application/x-javascript
text/javascript
text/x-javascript
text/x-json

But which one is correct, or best? I gather that there are security and browser support issues varying between them.
근데, 이중에서 뭐가 올바르거나 제일 좋은 가요? 보안과 브라우저 지원이 다르다는 것을 알고 있습니다.
I know there's a similar question, What MIME type if JSON is being returned by a REST API?, but I'd like a slightly more targeted answer.
이 질문과 비슷한 질문이 있는 것은 알고 있지만. 훨씬 더 정확한 답을 알고 싶습니다.


For JSON text:
JSON의 경우
application/json

The MIME media type for JSON text is application/json.
JSON text의 MIME 미디어 값은 application/json입니다.
The default encoding is UTF-8. (Source: RFC 4627).
인코딩은 UTF-8로 되어있습니다.

For JSONP (runnable JavaScript) with callback:

application/javascript


MIME 타입이란 클라이언트에게 전송된 문서의 다양성을 알려주기 위한 메커니즘.
브라우저들은 리소스를 내려받았을 때 해야 할 기본 동작이 무엇인지를 결정하기 위해 대게 MIME 타입을 사용

클라이언트에서 서버로 데이터를 전송하려 할 때, 데이터를 JSON 포멧으로 만들어서 보내는 것이 일반적인 형태 중 하나 입니다.

서버는 Rest API로 개발.
웹 페이지의 (javascript)를 이용해 json 포멧으로 데이터를 만들어서 요청하는 형식.

0개의 댓글