webservice에서 반환 된 json을 얻기 위해 angular2 typeScript를 사용하고 있습니다. get을 호출하면 WebService에서 값을 얻을 수 있지만 JSON의 구성 요소를 가져올 수 없습니다. 예를 들어 싶습니다. 반환 된 JSON의 상태를 가져옵니다. 전체 JSON을 얻을 수 있지만 JSON의 정확한 상태는 얻을 수 없습니다. 아래 webservice에서 반환 한 샘플 코드와 JSON을 볼 수 있습니다.JSON의 구성 요소를 얻는 방법 webservice 요청으로 반환하는 문자열
감사 Alper
샘플 코드 :
this.http.get(this.webServiceUrlGet)
.subscribe(
function (data) {
this.tradeShows = JSON.stringify(data);
console.log(this.tradeShows);
},
error => this.errorMessage = <any>error);
JSON :
"_body":"{\n \"args\": {}, \n \"headers\": {\n \"Accept\": \"application/json, text/plain, */*\", \n \"Accept-Encoding\": \"gzip, deflate, sdch, br\", \n \"Accept-Language\": \"tr-TR,tr;q=0.8,en-US;q=0.6,en;q=0.4\", \n \"Connect-Time\": \"0\", \n \"Connection\": \"close\", \n \"Host\": \"httpbin.org\", \n \"Origin\": \"http://localhost:3000\", \n \"Referer\": \"http://localhost:3000/navigation\", \n \"Total-Route-Time\": \"0\", \n \"User-Agent\": \"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Mobile Safari/537.36\", \n \"Via\": \"1.1 vegur\", \n \"X-Request-Id\": \"db6c93bd-99dd-4410-a709-5bc2dd4150fb\"\n }, \n \"origin\": \"212.175.18.38\", \n \"url\": \"https://httpbin.org/get\"\n}\n","status":200,"ok":true,"statusText":"OK","headers":{"Content-Type":["application/json"]},"type":2,"url":"https://httpbin.org/get"}
때문에
resp.json()
를 호출 할 필요가;' –전에 시도했지만 정의되지 않은 sachilla 알려줍니다. – user2307786
'JSON.parse (response)'가 필요하다. 귀하의 경우에 '데이터' –