Skip to content Skip to sidebar Skip to footer

Getting Data Into The Json

I am trying to visulize Coordinates on the map . Data is Coming form json. I am getting and error Push is undefined. I am passing the Array but getting error Here is the Code va

Solution 1:

You probably need to initialize geoCords to be an array before trying to push something.

testCtrl.geoCoords = [];

Solution 2:

You are trying to call push method on undefined You are doing this

testCtrl.geoCoords.push()

where testCtrl has no property geoCoords, so first initialize this property like

testCtrl.geoCoords = []

Now it is an empty array , you can use push method on this

Solution 3:

You could transform your json into Object, it might be easier after that.

privateObjectMappermapper=newObjectMapper();
listPersonCoordinates = mapper.readValue(query_result, newTypeReference<ArrayList<PersonCoordinate>>(){})
for (PersonCoordinate pc : listPersonCoordinate) {
    pc.getName();
    pc.getCoordinate();
    // Do your stuff here
}

and

publicClassPersonCoordinate{
    String name;
    ArrayList<double> coordinate;

    // getters + setters + constructor
}

Hope this help :)

Edit : Your JSON looks strangely formatted. misses some "

Post a Comment for "Getting Data Into The Json"