Package com.fasterxml.jackson.databind.node

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


        return schema;
    }
   
    protected ObjectNode createSchemaNode(String type, boolean isOptional)
    {
        ObjectNode schema = createSchemaNode(type);
        // as per [JACKSON-563]. Note that 'required' defaults to false
        if (!isOptional) {
            schema.put("required", !isOptional);
        }
        return schema;
    }
View Full Code Here


    ObjectDatastore datastore = new AnnotationObjectDatastore();
    datastore.store(message);
   
    // trigger receive event (not necessary)
    String event = "receive";
    ObjectNode params = JOM.createObjectNode();
    params.put("message", JOM.getInstance().convertValue(message, ObjectNode.class));
    trigger(event, params);
  }
View Full Code Here

      for (String url : to) {
        try {
          // create a task to send the message to this agent asynchronously
          // this is important, it parallelizes dispatching of the messages
          String method = "dispatch";
          ObjectNode params = JOM.createObjectNode();
          params.put("url", url);
          params.put("message", JOM.getInstance().convertValue(message, ObjectNode.class));
          JSONRequest request = new JSONRequest(method, params);
         
          long delay = 1; // milliseconds
         
          getScheduler().createTask(request, delay);
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }

    // trigger send event (not necessary)
    String event = "send";
    ObjectNode params = JOM.createObjectNode();
    params.put("message", JOM.getInstance().convertValue(message, ObjectNode.class));
    trigger(event, params);   
  }
View Full Code Here

   * @param message
   */
  public void dispatch (@Name("url") String url, @Name("message") Message message) {
    try {
      String method = "onMessage";
      ObjectNode params = JOM.createObjectNode();
      params.put("message", JOM.getInstance().convertValue(message, ObjectNode.class));

      send(url, method, params);
    } catch (Exception e) {
      e.printStackTrace();
    }
View Full Code Here

    }

    @Override
    public JsonNode getSchema(SerializerProvider provider, Type typeHint)
    {
        ObjectNode o = createSchemaNode("array", true);
        ObjectNode itemSchema = createSchemaNode("string"); //binary values written as strings?
        o.put("items", itemSchema);
        return o;
    }
View Full Code Here

    JID to = (recipients.length > 0) ? recipients[0] : null;
   
    String body = message.getBody();
    if (body != null && body.startsWith("{") || body.trim().startsWith("{")) {
      // the body contains a JSON object
      ObjectNode json = null;
      try {
        String agentUrl = "xmpp:" + to.getId();
        String agentId = xmppService != null ? xmppService
            .getAgentId(agentUrl) : null;
       
View Full Code Here

        for (Locale locale: Arrays.asList(Locale.getDefault(), Locale.ENGLISH, Locale.GERMAN, Locale.GERMANY)) {
            resourcesMap.putIfAbsent(locale, prepareLocalizedResources(locale));
        }
    }
    private ObjectNode prepareLocalizedResources(Locale locale) {
        ObjectNode resources = JsonNodeFactory.instance.objectNode();
        ObjectNode resourcesTree = JsonNodeFactory.instance.objectNode();
        resources.put("${symbol_dollar}tree", resourcesTree);

        Iterable<Map.Entry<Object, Object>> entries = Utils.IterableIterator.from(
                messageSource.getProperties(locale).entrySet(),
                applicationMessageSource.getProperties(locale).entrySet()
        );

        for (Map.Entry<Object, Object> entry: entries) {
            String key = entry.getKey().toString();
            String value = entry.getValue().toString();

            String[] keyParts = key.split("${symbol_escape}${symbol_escape}.");

            // go down the object properties
            ObjectNode node = resourcesTree;
            for (String keyPart : keyParts) {
                JsonNode child = node.get(keyPart);
                ObjectNode childObject;

                if (child == null) {
                    childObject = JsonNodeFactory.instance.objectNode();
                    node.put(keyPart, childObject);
                } else {
View Full Code Here

    @RequestMapping(value = "/resources", produces = "application/json")
    @ResponseBody
    @IfNoneMatch
    public JSONPObject getResources(Locale locale) {
        ObjectNode localizedResources = resourcesMap.get(locale);
        if (localizedResources == null) {
            log.info("Creating locale resources for {}, consider doing this on initialization", locale);
            resourcesMap.putIfAbsent(locale, prepareLocalizedResources(locale));
        }
        return new JSONPObject("R.registerResources", resourcesMap.get(locale));
View Full Code Here

  public void shouldGetElements() throws Exception {
    String json = "{\"object\":{\"subkey\":\"subvalue\"}, \"array\":[\"elem1\", \"elem2\"], \"boolean\":true, \"number\":55, \"string\":\"foo\", \"null\": null}";
    JsonNode node = new ObjectMapper().readTree(json);

    ObjectNode objElem = (ObjectNode) valueReader.get(node, "object");
    assertEquals(objElem.get("subkey").asText(), "subvalue");

    ArrayNode arrayElem = (ArrayNode) valueReader.get(node, "array");
    assertEquals(Arrays.asList(arrayElem.get(0).asText(), arrayElem.get(1).asText()),
        Arrays.asList("elem1", "elem2"));
View Full Code Here

    final BigDecimal minAsk = getNumberIfPresent(tickerDataNode.path("min_ask").asText());
    final BigDecimal maxBid = getNumberIfPresent(tickerDataNode.path("max_bid").asText());
    BigDecimal volumeTradeCurrency = null;
    BigDecimal volumePriceCurrency = null;
    if (tickerDataNode instanceof ObjectNode) {
      final ObjectNode tickerDataObjectNode = (ObjectNode) tickerDataNode;
      final Iterator<Entry<String, JsonNode>> tickerDataFields = tickerDataObjectNode.fields();
      while (tickerDataFields.hasNext()) {
        final Entry<String, JsonNode> tickerDataEntry = tickerDataFields.next();
        if (tickerDataEntry.getKey().startsWith("vol_")) {
          if (volumeTradeCurrency == null)
            volumeTradeCurrency = getNumberIfPresent(tickerDataEntry.getValue().asText());
View Full Code Here

TOP

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

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.