我正在創建一個JSONArray並將其解析爲一個字符串,但因爲它甚至包含字符串而不是代碼,所以它不會輸出,因爲我需要它。如何在Java中創建一個包含Javascript代碼的JSONArray?
for(Place place: places){
locations.put("new google.maps.LatLng("+place.getContactData().getLatitude()+","+place.getContactData().getLongitude()+")");
}
return locations.toString();
它輸出爲:["new google.maps.LatLng(53.5608,9.96357)","new google.maps.LatLng(53.5608,9.96357)"]
,但我需要它不喜歡[new google.maps.LatLng(53.5608,9.96357),new google.maps.LatLng(53.5608,9.96357)]
引號由JavaScript被正確解釋。
和'[新google.maps.LatLng(53.5608 ,9.96357),新的google.maps.LatLng(53.5608,9.96357)]將會是JSON內部的一個字符串嗎?因爲如果沒有,那麼它是無效的JSON。 – 2013-02-25 11:40:08
JSON數據結構中沒有代碼,這種格式根本不支持。 – Henry 2013-02-25 11:41:10
好的,我明白了。謝謝! – Lester 2013-02-25 11:43:31