-1

I'm having hard time figuring whats going wrong with my codes, seem like there is a missing '}' in the string that i'm trying to parse. So basicalluy what i'm trying to do is to execute javascript code with the aide of javafx api,

javascript function

function fillWaypoints(location){
 ArrayWaypoints.push(location)
 
}

java codes to execute javascript

     @FXML
public void displayDirection(){
for(int i =0;i< lists.get(0).size() ;i++){
System.out.println("routes -->"+lists.get(0).get(i));
engine.executeScript("fillWaypoints("+lists.get(0).get(i)+")");   
}

The output of

lists.get(0).get(0) for example is 

{location: Antoine Vallasois Ave, Vacoas-Phoenix, England, stopover:true}

Nicky Larson
  • 43
  • 2
  • 7

1 Answers1

0

The javascript is (presumably) expecting an object literal, in JSON format. The string you are getting is not valid JSON. A valid JSON representation would be

{"location": "Antoine Vallasois Ave, Vacoas-Phoenix, England", "stopover":true}

Or, if you intend the location to be an array,

{"location": ["Antoine Vallasois Ave", "Vacoas-Phoenix", "England"], "stopover":true}
James_D
  • 201,275
  • 16
  • 291
  • 322