Google 지역 정보 호출 결과에서 데이터를 추출하려고합니다.JSON 구문 분석이 잘못되었습니다.
나는 다음과 같은 자바 스크립트를 실행하는 경우 :
alert(JSON.stringify(places[0].geometry.location));
I받을 예정으로 다음과 같은 출력 : 나는 위도 값과 실행을 추출 끝에 .lat 넣어 경우
{"lat":59.9138688,"lng":10.752245399999993}
:
alert(JSON.stringify(places[0].geometry.location.lat));
내가 얻을 :
,undefined
다음과 같이 나는 JSON.stringify없이 경고를 실행하는 경우 :
alert(places[0].geometry.location.lat);
내가 얻을 : 내가 잘못
function(){return a}
을 뭐하는 거지?
alert(places[0].geometry.location.lat.toString())
을보십시오. 이미 숫자를 반환합니다. 문자열을 만들고 싶다면'places [0] .geometry.location.lat.toString()'을 사용할 수 있습니다. – Roysh'location' 객체에'toJSON' 메소드가 있다고 생각합니다.'lat '와'lng' 함수가 직렬화 될 때 작동합니다. ''[0] .geometry.location.toJSON'은 무엇을 보여줄까요? – apsillers
내가 아는 한 toJSON 방법이 없습니다. –