Package com.fasterxml.jackson.databind.node

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


            }
        }
       
        private ArrayNode flattenResults()
        {
            final JsonNodeFactory factory = JsonNodeFactory.instance;
            ArrayNode flatArray = factory.arrayNode();
            for (Map.Entry<Integer,ArrayNode> entry : results.entrySet())
            {
                flatArray.addAll(entry.getValue());
            }
            return flatArray;
View Full Code Here


    assertEquals(1, collector.getNumStartEvents());
    assertTrue(morphline.process(record));   
   
    assertEquals(1, collector.getRecords().size());
    JsonNode rootNode = (JsonNode) new ObjectMapper().reader(JsonNode.class).readValues(file).next();
    JsonNodeFactory factory = new JsonNodeFactory(false);

    assertEquals(Arrays.asList(10), collector.getFirstRecord().get("/docId"));
    assertEquals(Arrays.asList(rootNode.get("links")), collector.getFirstRecord().get("/links"));
   
    assertEquals(Arrays.asList(factory.arrayNode()), collector.getFirstRecord().get("/links/backward"));
    assertEquals(factory.arrayNode(), rootNode.get("links").get("backward"));
   
    List expected = Arrays.asList(factory.arrayNode().add(20).add(40).add(60).add(true).add(false).add(32767).add(2147483647).add(9223372036854775807L).add(1.23).add(1.7976931348623157E308));
    assertEquals(expected, collector.getFirstRecord().get("/links/forward"));
    assertEquals(expected, collector.getFirstRecord().get("/links/forward/[]"));
    assertEquals(expected, collector.getFirstRecord().get("/links/forward[]"));
    assertEquals(Arrays.asList(rootNode.get("name")), collector.getFirstRecord().get("/name"));
    assertEquals(Arrays.asList("en-us", "en", "en-gb"), collector.getFirstRecord().get("/name/[]/language/[]/code"));
View Full Code Here

    assertEquals(1, collector.getNumStartEvents());
    assertTrue(morphline.process(record));   
   
    assertEquals(1, collector.getRecords().size());
    JsonNode rootNode = (JsonNode) new ObjectMapper().reader(JsonNode.class).readValues(file).next();
    JsonNodeFactory factory = new JsonNodeFactory(false);

    assertEquals(Arrays.asList(10), collector.getFirstRecord().get("/docId"));
    assertEquals(Arrays.asList(rootNode.get("links")), collector.getFirstRecord().get("/links"));
   
    assertEquals(Arrays.asList(factory.arrayNode()), collector.getFirstRecord().get("/links/backward"));
    assertEquals(factory.arrayNode(), rootNode.get("links").get("backward"));
   
    List expected = Arrays.asList(factory.arrayNode().add(20).add(40).add(60).add(true).add(false).add(32767).add(2147483647).add(9223372036854775807L).add(1.23).add(1.7976931348623157E308));
    assertEquals(expected, collector.getFirstRecord().get("/links/forward"));
    assertEquals(expected, collector.getFirstRecord().get("/links/forward/[]"));
    assertEquals(expected, collector.getFirstRecord().get("/links/forward[]"));
    assertEquals(Arrays.asList(rootNode.get("name")), collector.getFirstRecord().get("/name"));
    assertEquals(Arrays.asList("en-us", "en", "en-gb"), collector.getFirstRecord().get("/name/[]/language/[]/code"));
View Full Code Here

public class A {

  @View
  @MimeType.JSON
  public TreeNode index() throws IOException {
    JsonNodeFactory factory = JsonNodeFactory.instance;
    return factory.objectNode().set("foo", factory.textNode("bar"));
  }
View Full Code Here

    assertEquals(200, response.getStatusLine().getStatusCode());
    assertNotNull(response.getEntity());
    assertEquals("application/json;charset=ISO-8859-1", response.getEntity().getContentType().getValue());
    ObjectMapper mapper = new ObjectMapper();
    JsonNode tree = mapper.readTree(response.getEntity().getContent());
    JsonNodeFactory factory = JsonNodeFactory.instance;
    JsonNode expected = factory.objectNode().set("foo", factory.textNode("bar"));
    assertEquals(expected, tree);
  }
View Full Code Here

        } else {
            throw new IllegalArgumentException("Must have file with .csv, .tsv or .json suffix");
        }

        List<String> names = Lists.newArrayList(splitter.split(lines.get(0)));
        JsonNodeFactory nf = JsonNodeFactory.withExactBigDecimals(false);
        ArrayNode localData = nf.arrayNode();
        for (String line : lines.subList(1, lines.size())) {
            ObjectNode r = nf.objectNode();
            List<String> fields = Lists.newArrayList(splitter.split(line));
            Preconditions.checkState(names.size() == fields.size(), "Wrong number of fields, expected ", names.size(), fields.size());
            Iterator<String> ix = names.iterator();
            for (String field : fields) {
                r.put(ix.next(), field);
View Full Code Here

            fw = new FileWriter(dumpFile.getAbsoluteFile());
            bw = new BufferedWriter(fw);

            List<ByteArrayWrapper> keys = this.detailsDB.dumpKeys();
           
            JsonNodeFactory jsonFactory = new JsonNodeFactory(false);
            ObjectNode blockNode = jsonFactory.objectNode();
            JSONHelper.dumpBlock(blockNode, block, gasUsed,
                    this.getWorldState().getRootHash(),
                    keys, this);
           
            EtherObjectMapper mapper = new EtherObjectMapper();
View Full Code Here

            }
        }
       
        private ArrayNode flattenResults()
        {
            final JsonNodeFactory factory = JsonNodeFactory.instance;
            ArrayNode flatArray = factory.arrayNode();
            for (Map.Entry<Integer,ArrayNode> entry : results.entrySet())
            {
                flatArray.addAll(entry.getValue());
            }
            return flatArray;
View Full Code Here

    {
        // Riak streams the result back. Each message from Riak contains a int
        // that tells you what phase the result is from. The result from a phase
        // can span multiple messages. Each result chunk is a JSON array.
       
        final JsonNodeFactory factory = JsonNodeFactory.instance;
        final ObjectMapper mapper = new ObjectMapper();
        final Map<Integer, ArrayNode> resultMap = new LinkedHashMap<Integer, ArrayNode>();
       
        int phase = 0;
       
        for (RiakKvPB.RpbMapRedResp response : rawResponse)
        {
            if (response.hasPhase())
            {
                phase = response.getPhase();
            }
            if (response.hasResponse())
            {
                ArrayNode jsonArray;
                if (resultMap.containsKey(phase))
                {
                    jsonArray = resultMap.get(phase);
                }
                else
                {
                    jsonArray = factory.arrayNode();
                    resultMap.put(phase, jsonArray);
                }
               
                JsonNode responseJson;
                try
View Full Code Here

    void createCommsToken() throws IOException, GroovesharkException {
        String method = "getCommunicationToken";

        // Build JSON payload
        JsonNodeFactory nodeFactory = JsonNodeFactory.instance;
        ObjectNode rootNode = nodeFactory.objectNode();
        {
            // Header
            ObjectNode header = nodeFactory.objectNode();
            header.put("client", "mobileshark");
            header.put("clientRevision", "20120830");
            header.put("country", country);
            header.put("privacy", 0);
            header.put("session", phpSession);
View Full Code Here

TOP

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

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.