I have a JSON file like this:
{
"waypoints": [
{
"waypoint_index": 0,
"trips_index": 0,
"hint": "u_FYj4uKI=",
"name": "",
"location": [
28.068655,
41.180774
]
},
{
"waypoint_index": 4,
"trips_index": 0,
"hint": "KiKhg4uKI=",
"name": "",
"location": [
20.75179,
29.031869
]
}
}
I know if you want to create java objects, well, you have just to understand how JSON works.
{} -> object
[] -> array
but I could not!
How to convert Java object to This json file?
public class ResultOsrm {
public Waypoints waypoints;
}
public class Waypoints {
public List waypoint_index;
}
Main -
Gson gson = new GsonBuilder().create();
ResultOsrm resultOsrm=gson.fromJson(JsonFile,ResultOsrm.class);
System.out.println(resultOsrm);
I need just waypoint_index and location values