Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.json.*;
- public class routeParser{
- private JSONObject routeString;
- private JSONArray instructions;
- private String distance;
- private String eta;
- private String points;
- private String[][] route;
- public routeParser(String route) throws Exception{
- this.routeString = new JSONObject(route);
- this.distance = routeString.getString("distance");
- this.eta = routeString.getString("time");
- JSONArray temp = routeString.getJSONArray("paths");
- this.instructions = temp.getJSONArray(2);
- this.points = temp.getString(5);
- }
- public void parseRoute() throws Exception{
- route = new String[instructions.length()][3];
- for (int i = 0; i < instructions.length(); i++)
- {
- route[i][0] = instructions.getJSONObject(i).getString("text");
- route[i][1] = (String)instructions.getJSONObject(i).getString("time");
- route[i][2] = (String)instructions.getJSONObject(i).getString("distance");
- }
- }
- public String getDistance(){
- return distance;
- }
- public String getPoints(){
- return points;
- }
- public String getETA(){
- return eta;
- }
- public String[][] getRoute(){
- return route;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement