Package org.codehaus.jackson

Examples of org.codehaus.jackson.JsonNode


    return LEVEL_PROPERTY;
  }

  @Override
  Integer parse() throws ParseException {
    final JsonNode value = node.path(LEVEL_PROPERTY);
    if (value.isInt()) {
      return value.asInt();
    }
    throw new ParseException("Invalid property '" + LEVEL_PROPERTY + "': value is not an integer");
  }
View Full Code Here


  @Override
  public QueryNode parse(final CharSequence query, final CharSequence field)
  throws QueryNodeParseException {
    try {
      final JsonNode node = mapper.readTree(query.toString());
      final String fieldname = this.getFirstFieldName(node);
      final TopLevelQueryNode topNode = new TopLevelQueryNode();

      // check for node property
      if (fieldname.equals(NodePropertyParser.NODE_PROPERTY)) {
View Full Code Here

    return BOOST_PROPERTY;
  }

  @Override
  Float parse() throws ParseException {
    final JsonNode value = node.path(BOOST_PROPERTY);
    if (value.isFloatingPointNumber()) {
      return (float) value.asDouble();
    }
    throw new ParseException("Invalid property '" + BOOST_PROPERTY + "': value is not a float");
  }
View Full Code Here

    return CHILD_PROPERTY;
  }

  @Override
  ArrayQueryNode parse() throws ParseException {
    final JsonNode value = node.path(CHILD_PROPERTY);
    if (!value.isArray()) {
      throw new ParseException("Invalid property'" + CHILD_PROPERTY + "': value is not an array");
    }

    final ArrayQueryNode arrayNode = new ArrayQueryNode();

    final Iterator<JsonNode> elements = value.getElements();
    while (elements.hasNext()) {
      final JsonNode element = elements.next();

      // parse occur
      final OccurPropertyParser occurParser = new OccurPropertyParser(element, field);
      Modifier mod = null;
      if (occurParser.isPropertyDefined()) {
        mod = occurParser.parse();
      }

      // check if there is either a node or a twig property and parse it
      QueryNode queryNode = null;
      if (element.has(NodePropertyParser.NODE_PROPERTY)) {
        final NodePropertyParser nodeParser = new NodePropertyParser(element, field);
        queryNode = nodeParser.parse();
      }
      if (element.has(TwigPropertyParser.TWIG_PROPERTY)) {
        final TwigPropertyParser twigParser = new TwigPropertyParser(element, field);
        queryNode = twigParser.parse();
      }

      // check if either a node or twig property has been defined
View Full Code Here

    return DESCENDANT_PROPERTY;
  }

  @Override
  ArrayQueryNode parse() throws ParseException {
    final JsonNode value = node.path(DESCENDANT_PROPERTY);
    if (!value.isArray()) {
      throw new ParseException("Invalid property'" + DESCENDANT_PROPERTY + "': value is not an array");
    }

    final ArrayQueryNode arrayNode = new ArrayQueryNode();

    final Iterator<JsonNode> elements = value.getElements();
    while (elements.hasNext()) {
      final JsonNode element = elements.next();

      // parse occur
      final OccurPropertyParser occurParser = new OccurPropertyParser(element, field);
      Modifier mod = null;
      if (occurParser.isPropertyDefined()) {
        mod = occurParser.parse();
      }

      // parse level
      final LevelPropertyParser levelParser = new LevelPropertyParser(element, field);
      int level = -1;
      if (levelParser.isPropertyDefined()) {
        level = levelParser.parse();
      }

      // check if there is either a node or a twig property and parse it
      QueryNode queryNode = null;
      if (element.has(NodePropertyParser.NODE_PROPERTY)) {
        final NodePropertyParser nodeParser = new NodePropertyParser(element, field);
        queryNode = nodeParser.parse();
      }
      if (element.has(TwigPropertyParser.TWIG_PROPERTY)) {
        final TwigPropertyParser twigParser = new TwigPropertyParser(element, field);
        queryNode = twigParser.parse();
      }

      // check if either a node or twig property has been defined
View Full Code Here

   * </ul>
   */
  private SolrInputDocument parseObject(final String object)
  throws JsonProcessingException, IOException {
    final SolrInputDocument doc = new SolrInputDocument();
    final JsonNode node = mapper.readTree(object);
    doc.addField("id", node.path("ChargeDeviceId").asText());
    doc.addField("name", node.path("ChargeDeviceName").asText());
    doc.addField("DeviceController_facet", node.path("DeviceController").path("OrganisationName").asText());
    doc.addField("json", node);
    return doc;
  }
View Full Code Here

  public void process() throws IOException {
    final FileReader fileReader = new FileReader(new File(INPUT_FILE));
    final LineReader reader = new LineReader(fileReader);
    try {
      JsonNode obj;
      String line;
      while ((line = reader.readLine()) != null) {
        obj = mapper.readTree(line);
        this.convertRatedOutputCurrent(obj);
        this.convertRatedOutputVoltage(obj);
View Full Code Here

  private void convertRatedOutputkW(final JsonNode obj) {
    final Iterator<JsonNode> nodes = obj.path("Connector").iterator();
    while (nodes.hasNext()) {
      final ObjectNode node = (ObjectNode) nodes.next();
      final JsonNode current = node.path("RatedOutputkW");
      if (!current.isMissingNode() && !current.isNull()) {
        final double value = Double.parseDouble(current.asText());
        node.put("RatedOutputkW", value);
      }
      if (current.isNull()) {
        node.remove("RatedOutputkW");
      }
    }
  }
View Full Code Here

  private void convertRatedOutputVoltage(final JsonNode obj) {
    final Iterator<JsonNode> nodes = obj.path("Connector").iterator();
    while (nodes.hasNext()) {
      final ObjectNode node = (ObjectNode) nodes.next();
      final JsonNode current = node.path("RatedOutputVoltage");
      if (!current.isMissingNode() && !current.isNull()) {
        final int value = Integer.parseInt(current.asText());
        node.put("RatedOutputVoltage", value);
      }
      if (current.isNull()) {
        node.remove("RatedOutputVoltage");
      }
    }
  }
View Full Code Here

  private void convertRatedOutputCurrent(final JsonNode obj) {
    final Iterator<JsonNode> nodes = obj.path("Connector").iterator();
    while (nodes.hasNext()) {
      final ObjectNode node = (ObjectNode) nodes.next();
      final JsonNode current = node.path("RatedOutputCurrent");
      if (!current.isMissingNode() && !current.isNull()) {
        final int value = Integer.parseInt(current.asText());
        node.put("RatedOutputCurrent", value);
      }
      if (current.isNull()) {
        node.remove("RatedOutputCurrent");
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.codehaus.jackson.JsonNode

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.