Package com.fasterxml.jackson.databind.node

Examples of com.fasterxml.jackson.databind.node.ArrayNode


        String newUrl = null;
        JsonNode userJson = request().body().asJson();
        accountForm = form(AccountForm.class).bind(userJson);

        // Parcour des links du user;
        ArrayNode liens = (ArrayNode) userJson.get("links");
        for (JsonNode lien : liens) {
            if (lien.get("id") != null) {
                Form<Link> oneLienForm = form(Link.class).bind(lien);
                if (oneLienForm.hasErrors()) {
                    Map<String, Map<String, List<String>>> errors = new HashMap<String, Map<String, List<String>>>();
View Full Code Here


        Map<Long, Vote> votes = Vote.findVotesUserByProposalId(user);

        Map<Long, Pair<Double, Integer>> moyennes = Vote.caculMoyennes();

        ArrayNode result = new ArrayNode(JsonNodeFactory.instance);

        for (Proposal proposal : proposals) {

            ObjectNode proposalJson = Json.newObject();

            proposalJson.put("id", proposal.getId());
            proposalJson.put("title", proposal.getTitle());


            if (proposal.format != null) {
                ObjectNode formatJson = Json.newObject();
                formatJson.put("id", proposal.format.getId());
                formatJson.put("dureeMinutes", proposal.format.getDureeMinutes());
                formatJson.put("libelle", proposal.format.getLibelle());
                proposalJson.put("format", formatJson);
            } else {
                proposalJson.putNull("format");
            }

            if (proposal.statusProposal != null) {
                proposalJson.put("status", proposal.statusProposal.name());
            } else {
                proposalJson.putNull("status");
            }

            if (proposal.audience != null) {
                proposalJson.put("audience", proposal.audience.getTitle());
            } else {
                proposalJson.putNull("audience");
            }

            if (proposal.getSpeaker() != null) {
                ObjectNode speakerJson = Json.newObject();
                speakerJson.put("id", proposal.getSpeaker().id);
                speakerJson.put("fullname", proposal.getSpeaker().getFullname());
                speakerJson.put("avatar", proposal.getSpeaker().getAvatar());
                proposalJson.put("speaker", speakerJson);
            }

            Vote voteUser = votes.get(proposal.getId());
            if (voteUser != null) {
                proposalJson.put("vote", voteUser.getNote());
            } else {
                proposalJson.putNull("vote");
            }

            Pair<Double, Integer> moyenne = moyennes.get(proposal.getId());
            if (moyenne != null) {
                proposalJson.put("moyenne", moyenne.getLeft());
                proposalJson.put("nbvote", moyenne.getRight());
            } else {
                proposalJson.putNull("moyenne");
            }

            result.add(proposalJson);
        }

        return ok(result);
    }
View Full Code Here

        ObjectNode proposalJson = Json.newObject();
        proposalJson.put("id", proposal.getId());
        proposalJson.put("title", proposal.getTitle());
        proposalJson.put("description", proposal.getDescription());
        proposalJson.put("indicationsOrganisateurs", proposal.getIndicationsOrganisateurs());
        ArrayNode tags = new ArrayNode(JsonNodeFactory.instance);
        for (Tag tag : proposal.getTags()) {
            tags.add(tag.nom);
        }
        proposalJson.put("tags", tags);

        ArrayNode speakers = new ArrayNode(JsonNodeFactory.instance);
        if (proposal.getSpeaker() != null) {
            speakers.add(getSpeakerInJson(proposal.getSpeaker()));
        }
        for (User otherSpeaker : proposal.getCoSpeakers()) {
            speakers.add(getSpeakerInJson(otherSpeaker));
        }
        proposalJson.put("speakers", speakers);
        return proposalJson;
    }
View Full Code Here

        return ok(writer.toString(), "ISO-8859-1");
    }

    public static Result acceptedSpeakersToJson(String callback) {

        ArrayNode result = getAcceptedProposalsToJson();
        return ok(jsonp(callback, result));
    }
View Full Code Here

        // speaker.proposals.id
        // speaker.proposals.title
        // speaker.proposals.description
        // speaker.proposals.otherspeakers

        ArrayNode result = new ArrayNode(JsonNodeFactory.instance);
        for (User speaker : speakersSorted) {
            ObjectNode speakerJson = getSpeakerInJson(speaker);
            ArrayNode proposalsJson = new ArrayNode(JsonNodeFactory.instance);
            for (Proposal proposal : speakers.get(speaker)) {
                ObjectNode proposalJson = Json.newObject();
                proposalJson.put("id", proposal.getId());
                proposalJson.put("title", proposal.getTitle());
                proposalJson.put("description", proposal.getDescription());
                proposalJson.put("indicationsOrganisateurs", proposal.getIndicationsOrganisateurs());
                ArrayNode otherSpeakers = new ArrayNode(JsonNodeFactory.instance);
                if (proposal.getSpeaker() != null && !speaker.equals(proposal.getSpeaker())) {
                    otherSpeakers.add(getSpeakerInJson(proposal.getSpeaker()));
                }
                for (User otherSpeaker : proposal.getCoSpeakers()) {
                    if (!otherSpeaker.equals(speaker)) {
                        otherSpeakers.add(getSpeakerInJson(otherSpeaker));
                    }
                }
                proposalJson.put("otherspeakers", otherSpeakers);
                proposalsJson.add(proposalJson);
            }
View Full Code Here

        // proposal.speaker.links.url
        // proposal.speaker.links.label
        // proposal.coSpeakers

        List<Proposal> proposalsAccepted = Proposal.findByStatusForMinimalData(Proposal.Status.ACCEPTED);
        ArrayNode result = new ArrayNode(JsonNodeFactory.instance);
        for (Proposal proposal : proposalsAccepted) {
            ObjectNode proposalJson = Json.newObject();
            proposalJson.put("id", proposal.getId());
            proposalJson.put("title", proposal.getTitle());
            proposalJson.put("description", proposal.getDescription());
            proposalJson.put("indicationsOrganisateurs", proposal.getIndicationsOrganisateurs());

            if (proposal.getSpeaker() != null) {
                proposalJson.put("speaker", getSpeakerInJson(proposal.getSpeaker()));
            }
            ArrayNode coSpeakers = new ArrayNode(JsonNodeFactory.instance);
            for (User speaker : proposal.getCoSpeakers()) {
                coSpeakers.add(getSpeakerInJson(speaker));
            }
            proposalJson.put("coSpeakers", coSpeakers);
            result.add(proposalJson);
        }
        return ok(jsonp(callback, result));
View Full Code Here

        speakerJson.put("id", speaker.id);
        speakerJson.put("fullname", speaker.getFullname());
        speakerJson.put("avatar", speaker.getAvatar());
        speakerJson.put("description", speaker.description);

        ArrayNode liens = new ArrayNode(JsonNodeFactory.instance);
        for (Link link : speaker.getLinks()) {
            ObjectNode lienJson = Json.newObject();
            lienJson.put("url", link.url);
            lienJson.put("label", link.label);
            liens.add(lienJson);
        }
        speakerJson.put("links", liens);
        return speakerJson;
    }
View Full Code Here

    }


    @Test
    public void list_of_numbers() {
        ArrayNode objs = using(JACKSON_TREE_CONFIGURATION).parse(JSON_DOCUMENT).read("$.store.book[*].display-price");
        System.out.println(objs.toString());
    }
View Full Code Here

    @Override
    public void setProperty(Object obj, Object key, Object value) {
        if (isMap(obj))
            toJsonObject(obj).put(key.toString(), createJsonElement(value));
        else {
            ArrayNode array = toJsonArray(obj);
            int index;
            if (key != null) {
                index = key instanceof Integer ? (Integer) key : Integer.parseInt(key.toString());
            } else {
                index = array.size();
            }
            if (index == array.size()) {
                array.add(createJsonElement(value));
            } else {
                array.set(index, createJsonElement(value));
            }
        }
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    public void removeProperty(Object obj, Object key) {
        if (isMap(obj))
            toJsonObject(obj).remove(key.toString());
        else {
            ArrayNode array = toJsonArray(obj);
            int index = key instanceof Integer ? (Integer) key : Integer.parseInt(key.toString());
            array.remove(index);
        }
    }
View Full Code Here

TOP

Related Classes of com.fasterxml.jackson.databind.node.ArrayNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.