Written by
java-style
on
on
[JSON] json()
[JSON] json()
728x90
json()
The json() method of the Response interface takes a Response stream and reads it to completion. It returns a promise which resolves with the result of parsing the body text as JSON.
Note that despite the method being named json(), the result is not JSON but is instead the result of taking JSON as input and parsing it to produce a JavaScript object.
Response 인터페이스의 json() 메서드는 Response 스트림을 가져와 완료할 때까지 읽습니다. 본문 텍스트를 JSON으로 구문 분석한 결과로 해결되는 약속을 반환합니다.
메서드 이름이 json()임에도 불구하고 결과는 JSON이 아니라 JSON을 입력으로 사용하고 이를 구문 분석하여 JavaScript 객체를 생성한 결과입니다.
즉, 받아온 데이터를 JSON.parse()를 해주는 것과 동일하다.
출처: https://developer.mozilla.org/en-US/docs/Web/API/Response/json
반응형
from http://codingbucks.tistory.com/246 by ccl(A) rewrite - 2021-12-28 15:01:44