Example usage for com.google.gson JsonObject getAsJsonObject

List of usage examples for com.google.gson JsonObject getAsJsonObject

Introduction

In this page you can find the example usage for com.google.gson JsonObject getAsJsonObject.

Prototype

public JsonObject getAsJsonObject(String memberName) 

Source Link

Document

Convenience method to get the specified member as a JsonObject.

Usage

From source file:com.rackspacecloud.client.cloudfiles.FilesClient.java

License:Open Source License

public boolean loginKeystone() throws UnknownHostException, SocketException, IOException, UnauthorizeException {
    isLoggedin = false;//from  w ww  .  j a v  a  2s .c  om

    String tenantNameKeystone = "";
    String userNameKeystone = username;
    if (username.split(":").length >= 2) {
        tenantNameKeystone = username.split(":")[0];
        userNameKeystone = username.split(":")[1];
    }

    String content = "{\"auth\": {\"passwordCredentials\": {\"username\": \"" + userNameKeystone
            + "\", \"password\": \"" + password + "\"}, \"tenantName\":\"" + tenantNameKeystone + "\"}}";

    HttpPost method = new HttpPost(authenticationURL);
    method.getParams().setIntParameter("http.socket.timeout", connectionTimeOut);
    method.setHeader("Content-type", "application/json");

    InputStream stream = new ByteArrayInputStream(content.getBytes("UTF-8"));
    InputStreamEntity entity = new InputStreamEntity(stream, content.getBytes("UTF-8").length);
    method.setEntity(entity);

    stream.close();

    FilesResponse response = new FilesResponse(client.execute(method));

    if (response.getStatusCode() == 401) {
        throw new UnauthorizeException("Incorrect user/password.", response.getResponseHeaders(),
                response.getStatusLine());
    }

    InputStream in = response.getResponseBodyAsStream();
    String outString = IOUtils.toString(in, "UTF-8");
    in.close();

    JsonElement jelement = new JsonParser().parse(outString);
    JsonObject jobject = jelement.getAsJsonObject();

    jobject = jobject.getAsJsonObject("access");
    jobject = jobject.getAsJsonObject("token");
    authToken = jobject.get("id").getAsString();

    jobject = jelement.getAsJsonObject();
    jobject = jobject.getAsJsonObject("access");

    JsonArray jarray = jobject.getAsJsonArray("serviceCatalog");

    for (JsonElement serviceCatalog : jarray) {
        JsonObject jsonLineItem = serviceCatalog.getAsJsonObject();

        String value = jsonLineItem.get("type").getAsString();

        if (value.compareTo("object-store") == 0) {
            JsonArray jarray2 = jsonLineItem.getAsJsonArray("endpoints");
            JsonElement endpoint = jarray2.get(0);
            storageURL = endpoint.getAsJsonObject().get("publicURL").getAsString();

            isLoggedin = true;
            cdnManagementURL = "";

            break;
        }
    }

    logger.debug("storageURL: " + storageURL);
    logger.debug("authToken: " + authToken);
    logger.debug("cdnManagementURL:" + cdnManagementURL);
    logger.debug("ConnectionManager:" + client.getConnectionManager());

    return isLoggedin;
}

From source file:com.rackspacecloud.client.cloudfiles.FilesClient.java

License:Open Source License

public boolean loginKeystoneV3()
        throws UnknownHostException, SocketException, IOException, UnauthorizeException {
    isLoggedin = false;//from  w w w.  j  av a2 s . com

    String tenantNameKeystone = "";
    String userNameKeystone = username;
    if (username.split(":").length >= 2) {
        tenantNameKeystone = username.split(":")[0];
        userNameKeystone = username.split(":")[1];
    }

    String content = "{\"auth\": {\"identity\": {\"methods\": [\"password\"],\"password\": {\"user\":{\"domain\": {\"name\": \"d_Stacksync\"},\"name\": \""
            + userNameKeystone + "\",\"password\": \"" + password
            + "\"}}},\"scope\": {\"project\": {\"domain\": {\"name\": \"d_Stacksync\"},\"name\": \""
            + tenantNameKeystone + "\"}}}}";
    //String content = "{\"auth\": {\"passwordCredentials\": {\"username\": \"" + userNameKeystone + "\", \"password\": \"" + password + "\"}, \"tenantName\":\"" + tenantNameKeystone + "\"}}";

    HttpPost method = new HttpPost(authenticationURL);
    method.getParams().setIntParameter("http.socket.timeout", connectionTimeOut);
    method.setHeader("Content-type", "application/json");

    InputStream stream = new ByteArrayInputStream(content.getBytes("UTF-8"));
    InputStreamEntity entity = new InputStreamEntity(stream, content.getBytes("UTF-8").length);
    method.setEntity(entity);

    stream.close();

    FilesResponse response = new FilesResponse(client.execute(method));

    if (response.getStatusCode() == 401) {
        throw new UnauthorizeException("Incorrect user/password.", response.getResponseHeaders(),
                response.getStatusLine());
    }

    InputStream in = response.getResponseBodyAsStream();
    String outString = IOUtils.toString(in, "UTF-8");
    in.close();

    Header header = response.getResponseHeaders("X-Subject-Token")[0];
    authToken = header.getValue();

    JsonElement jelement = new JsonParser().parse(outString);
    JsonObject jobject = jelement.getAsJsonObject();

    //jobject = jelement.getAsJsonObject();
    jobject = jobject.getAsJsonObject("token");

    JsonArray jarray = jobject.getAsJsonArray("catalog");

    for (JsonElement serviceCatalog : jarray) {
        JsonObject jsonLineItem = serviceCatalog.getAsJsonObject();

        String value = jsonLineItem.get("type").getAsString();

        if (value.compareTo("object-store") == 0) {
            JsonArray jarray2 = jsonLineItem.getAsJsonArray("endpoints");

            for (JsonElement endpoint : jarray2) {
                JsonObject endpointObject = endpoint.getAsJsonObject();
                String publicURL = endpointObject.get("interface").getAsString();
                if (publicURL.compareTo("public") == 0) {
                    storageURL = endpointObject.get("url").getAsString();
                    isLoggedin = true;
                    cdnManagementURL = "";

                    break;
                }
            }
        }
    }

    logger.debug("storageURL: " + storageURL);
    logger.debug("authToken: " + authToken);
    logger.debug("cdnManagementURL:" + cdnManagementURL);
    logger.debug("ConnectionManager:" + client.getConnectionManager());

    return isLoggedin;
}

From source file:com.redcanari.ui.WebKitBrowser.java

License:Open Source License

private void createDetailPane() {
    detailPane = new TabPane();

    javaScriptConsoleTab = new JavaScriptConsoleTab(webEngine);
    addErrorListener(javaScriptConsoleTab::handleError);
    addAlertListener(javaScriptConsoleTab::handleAlert);

    crossSiteScriptingTrackerTab = new CrossSiteScriptingTrackerTab(webEngine);
    addAlertListener(crossSiteScriptingTrackerTab::handleAlert);

    pageResourcesTab = new PageResourcesTab(webEngine);

    promptDialog = new JSInputDialog();

    Tab javaScriptEditorTab = new Tab("BurpScript IDE");
    javaScriptEditorTab.selectedProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue)
            masterDetailPane.setDividerPositions(0.5);
    });/*w  ww.j a v  a 2 s.  c o  m*/
    JavaScriptEditor javaScriptEditor = new JavaScriptEditor(webEngine, controller, false);
    javaScriptEditor.setJavaScriptConsoleTab(javaScriptConsoleTab);
    javaScriptEditorTab.setContent(javaScriptEditor);

    Tab trafficBrowserTab = new Tab("Network");
    trafficBrowser = new TrafficBrowser();
    trafficBrowserTab.setContent(trafficBrowser);

    Debugger debugger = webEngine.impl_getDebugger();
    debugger.setEnabled(true);
    debugger.sendMessage("{\"id\": 1, \"method\":\"Network.enable\"}");
    debugger.setMessageCallback(new Callback<String, Void>() {

        ConcurrentHashMap<String, Traffic> trafficState = new ConcurrentHashMap<>();

        @Override
        public Void call(String param) {
            JsonParser parser = new JsonParser();
            JsonObject object = parser.parse(param).getAsJsonObject();

            String method = object.get("method").getAsString();
            JsonObject params = object.getAsJsonObject("params");
            JsonObject request = params.getAsJsonObject("request");
            JsonObject response = params.getAsJsonObject("response");
            String requestId = params.get("requestId").getAsString();

            Instant timeStamp;
            JsonElement epochObject = params.get("timestamp");
            if (epochObject != null) {
                double epoch = epochObject.getAsDouble();
                timeStamp = Instant.ofEpochSecond((long) Math.floor(epoch),
                        (long) (epoch * 1000000000 % 1000000000));
            } else {
                timeStamp = Instant.now();
            }

            Traffic traffic = null;

            switch (method) {
            case "Network.requestWillBeSent":
                URL url = null;
                String urlString = request.get("url").getAsString();

                try {
                    url = new URL(urlString);
                } catch (MalformedURLException e) {
                    //                            e.printStackTrace();
                }
                trafficState.put(requestId,
                        new Traffic((url == null) ? urlString : url.getFile(), timeStamp,
                                (url == null) ? "" : url.getHost(), request.get("method").getAsString(),
                                params.get("documentURL").getAsString()));
                break;
            case "Network.responseReceived":
                traffic = trafficState.get(requestId);
                JsonObject headers = response.getAsJsonObject("headers");
                JsonElement contentType = headers.get("Content-Type");
                JsonElement contentLength = headers.get("Content-Length");
                traffic.setType((contentType == null) ? "" : contentType.getAsString());
                JsonElement requestLine = headers.get("");
                if (requestLine != null) {
                    String[] requestLineParts = requestLine.getAsString().split(" ", 3);
                    traffic.setStatusCode(new Integer(requestLineParts[1]));
                    traffic.setStatusText(requestLineParts[2]);
                    traffic.setSize((contentLength == null) ? "0" : contentLength.getAsString());
                } else {
                    traffic.setStatusCode(200);
                    traffic.setStatusText("OK");
                    traffic.setSize("0");
                }
                break;
            case "Network.loadingFinished":
                traffic = trafficState.get(requestId);
                traffic.setEndTime(timeStamp);
                trafficBrowser.getTraffic().add(traffic);
                trafficState.remove(requestId);
                if (traffic.getEndTime().isAfter(trafficBrowser.getEndTime())) {
                    trafficBrowser.setEndTime(traffic.getEndTime());
                }
            }
            return null;
        }
    });

    detailPane.getTabs().addAll(javaScriptConsoleTab, crossSiteScriptingTrackerTab, pageResourcesTab,
            trafficBrowserTab, javaScriptEditorTab
    //                new ImagesTab(webEngine)
    );

    detailPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE);
}

From source file:com.remediatetheflag.global.actions.auth.management.team.PostReviewAction.java

License:Apache License

@Override
public void doAction(HttpServletRequest request, HttpServletResponse response) throws Exception {

    User user = (User) request.getSession().getAttribute(Constants.ATTRIBUTE_SECURITY_CONTEXT);
    JsonObject json = (JsonObject) request.getAttribute(Constants.REQUEST_ATTRIBUTE_JSON);
    JsonObject jsonObj = json.getAsJsonObject(Constants.JSON_ATTRIBUTE_OBJ);

    Gson gson = new Gson();
    SubmittedReview review = gson.fromJson(jsonObj, SubmittedReview.class);

    if (review.getAwardTrophy() == null || review.getId() == null || review.getNewIssuesIntroduced() == null
            || review.getTotalScore() == null || review.getReview() == null || review.getReview().isEmpty()) {
        logger.error("Invalid data supplied for review from user " + user.getIdUser());
        MessageGenerator.sendErrorMessage("InvalidData", response);
        return;/* w ww  .ja va  2  s .  c  om*/
    }

    Integer exerciseInstanceId = review.getId();
    Boolean awardTrophy = review.getAwardTrophy();
    Boolean newIssuesIntroduced = review.getNewIssuesIntroduced();
    String newIssuesIntroducedText = review.getNewIssuesIntroducedText();

    ExerciseInstance reviewedInstance = hpc.getManagementCompletedExerciseInstance(exerciseInstanceId,
            user.getManagedOrganizations());
    if (null == reviewedInstance) {
        logger.error("Exercise " + exerciseInstanceId + " not found for user " + user.getIdUser());
        MessageGenerator.sendErrorMessage("NotFound", response);
        return;
    }
    if (user.getRole().equals(Constants.ROLE_TEAM_MANAGER)) {
        List<User> users = hpc.getUsersInTeamManagedBy(user);
        if (!users.contains(reviewedInstance.getUser())) {
            MessageGenerator.sendErrorMessage("NotFound", response);
            return;
        }
    }
    if (reviewedInstance.getStatus().equals(ExerciseStatus.REVIEWED)
            || reviewedInstance.getStatus().equals(ExerciseStatus.REVIEWED_MODIFIED)
            || reviewedInstance.getStatus().equals(ExerciseStatus.CANCELLED)) {
        logger.error("Exercise " + exerciseInstanceId + " already reviewer for user " + user.getIdUser());
        MessageGenerator.sendErrorMessage("NotFound", response);
        return;
    }
    Integer totalScore = 0;
    if (reviewedInstance.getResults().isEmpty()) {
        for (ExerciseResult rev : review.getReview()) {
            ExerciseResult res = new ExerciseResult();
            res.setName(rev.getName());
            res.setComment(rev.getComment());
            res.setVerified(true);
            res.setStatus(rev.getStatus());
            res.setLastChange(new Date());
            res.setScore(rev.getScore());
            totalScore += rev.getScore();
            res.setAutomated(false);
            res.setCategory(getCategoryForResult(reviewedInstance, rev.getName()));
            reviewedInstance.getResults().add(res);
        }
    } else {
        for (ExerciseResult orig : reviewedInstance.getResults()) {
            for (ExerciseResult rev : review.getReview()) {
                if (rev.getName().equals(orig.getName())) {
                    orig.setComment(rev.getComment());
                    orig.setVerified(true);
                    orig.setLastChange(new Date());
                    orig.setStatus(rev.getStatus());
                    orig.setScore(rev.getScore());
                    totalScore += rev.getScore();
                    orig.setAutomated(false);
                }
            }
        }
    }

    //TODO compute total score from individual questions and remove from parameters
    reviewedInstance.getScore().setResult(totalScore);
    reviewedInstance.setResultsAvailable(true);
    reviewedInstance.setStatus(ExerciseStatus.REVIEWED);
    reviewedInstance.setTrophyAwarded(review.getAwardTrophy());
    reviewedInstance.setNewIssuesIntroduced(newIssuesIntroduced);
    if (newIssuesIntroduced) {
        reviewedInstance.setNewIssuesIntroducedText(newIssuesIntroducedText);
    }
    reviewedInstance.setReviewer(user.getIdUser());
    reviewedInstance.setReviewedDate(new Date());
    hpc.updateExerciseInstance(reviewedInstance);
    if (reviewedInstance.getType().equals(ExerciseInstanceType.CHALLENGE)) {
        Challenge c = hpc.getChallengeFromId(reviewedInstance.getChallengeId());
        c.setLastActivity(new Date());
        hpc.updateChallenge(c);
    }
    notificationsHelper.addCompletedReviewNotification(reviewedInstance.getUser(), reviewedInstance);

    List<ExerciseInstance> userRunExercises = hpc
            .getCompletedExerciseInstancesForUser(reviewedInstance.getUser().getIdUser());
    boolean alreadyRun = false;
    for (ExerciseInstance runEx : userRunExercises) {
        if (runEx.getAvailableExercise().getId().equals(reviewedInstance.getAvailableExercise().getId())
                || runEx.getAvailableExercise().getUuid()
                        .equals(reviewedInstance.getAvailableExercise().getUuid())) {
            alreadyRun = true;
            break;
        }
    }
    if (!alreadyRun) {
        User dbUser = hpc.getUserFromUserId(reviewedInstance.getUser().getIdUser());
        dbUser.setExercisesRun(dbUser.getExercisesRun() + 1);
        dbUser.setScore(dbUser.getScore() + reviewedInstance.getScore().getResult());
        hpc.updateUserInfo(dbUser);

        List<AchievedTrophy> userAchievedTrophy = hpc.getAllAchievedTropiesForUser(user.getIdUser());
        boolean alreadyAchieved = false;
        for (AchievedTrophy trophy : userAchievedTrophy) {
            if (trophy.getTrophy().getName()
                    .equals(reviewedInstance.getAvailableExercise().getTrophy().getName())) {
                alreadyAchieved = true;
                break;
            }
        }
        if (awardTrophy && !alreadyAchieved) {
            AchievedTrophy t = new AchievedTrophy();
            t.setDate(new Date());
            t.setUser(reviewedInstance.getUser());
            t.setTrophy(reviewedInstance.getAvailableExercise().getTrophy());
            hpc.managementAddAchievedTrophy(t);
        }
    }

    logger.debug("Review submitted for exercise " + exerciseInstanceId + " from reviewer " + user.getIdUser());
    MessageGenerator.sendSuccessMessage(response);

}

From source file:com.replaymod.replaystudio.launcher.Launcher.java

License:MIT License

public void parseConfig(Studio studio, JsonObject root) {
    JsonArray instructions = root.getAsJsonArray("Instructions");
    for (JsonElement e : instructions) {
        JsonObject o = e.getAsJsonObject();
        Instruction instruction;/*from www . j a  va  2  s  .  c o m*/
        switch (o.get("Name").getAsString().toLowerCase()) {
        case "split":
            if (o.get("at").isJsonArray()) {
                List<Long> at = new ArrayList<>();
                Iterables.addAll(at,
                        Iterables.transform(o.getAsJsonArray("at"), (e1) -> timeStampToMillis(e1.toString())));
                instruction = new SplitInstruction(Longs.toArray(at));
            } else {
                instruction = new SplitInstruction(timeStampToMillis(o.get("at").toString()));
            }
            break;
        case "append":
            instruction = new AppendInstruction();
            break;
        case "squash":
            instruction = new SquashInstruction(studio);
            break;
        case "copy":
            instruction = new CopyInstruction();
            break;
        case "filter":
            Filter filter = studio.loadFilter(o.get("Filter").toString());
            instruction = new FilterInstruction(studio, filter, o.getAsJsonObject("Config"));
            break;
        default:
            System.out.println("Warning: Unrecognized instruction in json config: " + o.get("Name"));
            continue;
        }

        JsonElement inputs = o.get("Inputs");
        if (inputs.isJsonArray()) {
            for (JsonElement e1 : inputs.getAsJsonArray()) {
                instruction.getInputs().add(e1.getAsString());
            }
        } else {
            instruction.getInputs().add(inputs.getAsString());
        }

        JsonElement outputs = o.get("Outputs");
        if (outputs.isJsonArray()) {
            for (JsonElement e1 : outputs.getAsJsonArray()) {
                instruction.getOutputs().add(e1.getAsString());
            }
        } else {
            instruction.getOutputs().add(outputs.getAsString());
        }

        this.instructions.add(instruction);
    }

    // Get all inputs
    JsonObject inputs = root.getAsJsonObject("Inputs");
    for (Map.Entry<String, JsonElement> e : inputs.entrySet()) {
        this.inputs.put(e.getKey(), e.getValue().getAsString());
    }

    // Get all outputs
    JsonObject outputs = root.getAsJsonObject("Outputs");
    for (Map.Entry<String, JsonElement> e : outputs.entrySet()) {
        this.outputs.put(e.getKey(), e.getValue().getAsString());
    }

    // Calculate all pipes
    for (Instruction instruction : this.instructions) {
        pipes.addAll(instruction.getInputs());
        pipes.addAll(instruction.getOutputs());
    }
    pipes.removeAll(this.inputs.keySet());
    pipes.removeAll(this.outputs.keySet());
}

From source file:com.replaymod.replaystudio.replay.AbstractReplayFile.java

License:MIT License

@Override
public Optional<Set<Marker>> getMarkers() throws IOException {
    Optional<InputStream> in = get(ENTRY_MARKERS);
    if (in.isPresent()) {
        try (Reader is = new InputStreamReader(in.get())) {
            JsonArray json = new Gson().fromJson(is, JsonArray.class);
            Set<Marker> markers = new HashSet<>();
            for (JsonElement element : json) {
                JsonObject obj = element.getAsJsonObject();
                JsonObject value = obj.getAsJsonObject("value");
                JsonObject position = value.getAsJsonObject("position");
                Marker marker = new Marker();
                marker.setTime(obj.get("realTimestamp").getAsInt());
                marker.setX(position.get("x").getAsDouble());
                marker.setY(position.get("y").getAsDouble());
                marker.setZ(position.get("z").getAsDouble());
                marker.setYaw(position.get("yaw").getAsFloat());
                marker.setPitch(position.get("pitch").getAsFloat());
                marker.setRoll(position.get("roll").getAsFloat());
                if (value.has("name")) {
                    marker.setName(value.get("name").getAsString());
                }//from  w  w  w.  ja  v  a  2s. co m
                markers.add(marker);
            }
            return Optional.of(markers);
        }
    }
    return Optional.absent();
}

From source file:com.samsung.sjs.JSEnvironment.java

License:Apache License

public void parseDecl(JsonObject decl) {
    String name = decl.getAsJsonPrimitive("name").getAsString();
    if (decl.getAsJsonPrimitive("intrinsic") != null) {
        assert (decl.getAsJsonPrimitive("intrinsic").getAsBoolean());
        parseIntrinsic(name, decl.getAsJsonObject("type"));
    } else {/*  w  ww. j a v a2  s  .c  o m*/
        Type t = parseType(decl.getAsJsonObject("type"));
        put(name, t);
        if (t instanceof ConstructorType) {
            namedTypes.put(name, (ObjectType) ((ConstructorType) t).returnType());
        }
    }
}

From source file:com.samsung.sjs.JSEnvironment.java

License:Apache License

public Type parseType(JsonObject ty) {
    assert (ty != null);
    String typefamily = ty.getAsJsonPrimitive("typefamily").getAsString();
    switch (typefamily) {
    case "string":
        return Types.mkString();
    case "int":
        return Types.mkInt();
    case "double":
        return Types.mkFloat();
    case "void":
        return Types.mkVoid();
    case "bool":
        return Types.mkBool();
    case "array":
        Type etype = parseType(ty.getAsJsonObject("elemtype"));
        return Types.mkArray(etype);
    case "map":
        Type mtype = parseType(ty.getAsJsonObject("elemtype"));
        return Types.mkMap(mtype);
    case "constructor":
    case "function":
    case "method":
        final Type ret = parseType(ty.getAsJsonObject("return"));
        final List<String> names = new LinkedList<String>();
        final List<Type> types = new LinkedList<Type>();
        for (JsonElement e : ty.getAsJsonArray("args")) {
            JsonObject eo = e.getAsJsonObject();
            names.add(eo.getAsJsonPrimitive("name").getAsString());
            types.add(parseType(eo.getAsJsonObject("type")));
        }//  w  ww .  ja v  a 2  s.  c o m
        if (typefamily.equals("function")) {
            return Types.mkFunc(ret, types, names);
        } else if (typefamily.equals("constructor")) {
            return Types.mkCtor(types, names, ret, null);
        } else {
            // method
            assert (typefamily.equals("method"));
            return Types.mkMethod(Types.mkAny(), ret, names, types); // TODO: Why does AttachedMethodType have a receiver?
        }
    case "object":
        final List<Property> props = new LinkedList<Property>();
        for (JsonElement e : ty.getAsJsonArray("members")) {
            JsonObject eo = e.getAsJsonObject();
            props.add(parseProp(eo));
        }
        ObjectType o = Types.mkObject(props);
        if (ty.has("typename")) {
            namedTypes.put(ty.getAsJsonPrimitive("typename").getAsString(), o);
        }
        return o;

    case "intersection":
        List<Type> mems = new LinkedList<>();
        for (JsonElement e : ty.getAsJsonArray("members")) {
            JsonObject eo = e.getAsJsonObject();
            mems.add(parseType(eo));
        }
        return new IntersectionType(mems);
    case "typevariable":
        int x = ty.getAsJsonPrimitive("id").getAsInt();
        return new TypeVariable(x);
    case "name":
        String name = ty.getAsJsonPrimitive("name").getAsString();
        return new NamedObjectType(name, this);
    default:
        throw new IllegalArgumentException(typefamily);
    }
}

From source file:com.samsung.sjs.JSEnvironment.java

License:Apache License

public Property parseProp(JsonObject p) {
    String name = p.getAsJsonPrimitive("name").getAsString();
    return Types.mkProperty(name, parseType(p.getAsJsonObject("type")));
}

From source file:com.shared.rides.service.SignupUserService.java

private void saveStop(JsonObject jsonDay, Pedestrian ped, int day, String personalId, String tagName,
        String inout) {//www . j  a v a  2s.  c  om
    JsonObject stopIn = jsonDay.getAsJsonObject(tagName);
    JsonElement lat = stopIn.get("lat");
    JsonElement lon = stopIn.get("lon");

    Stop stop = new Stop();

    stop.setDay(day + 1);

    if (inout.equalsIgnoreCase("in"))
        stop.setInout(0);
    else
        stop.setInout(1);

    stop.setLat(lat.getAsDouble());
    stop.setLon(lon.getAsDouble());

    stopDAO.save(stop);
    stop = stopDAO.getLastStop();
    pedDAO.newStop(ped.getPedestrianId(), stop.getStopId());
}