Examples of JsonNode


Examples of argo.jdom.JsonNode

        switch (jsonNode.getType()) {
            case ARRAY:
                writer.append('[');
                final Iterator<JsonNode> elements = jsonNode.getElements().iterator();
                while (elements.hasNext()) {
                    final JsonNode node = elements.next();
                    writer.println();
                    addTabs(writer, indent + 1);
                    formatJsonNode(node, writer, indent + 1);
                    if (elements.hasNext()) {
                        writer.append(",");
View Full Code Here

Examples of com.facebook.presto.hive.shaded.org.codehaus.jackson.JsonNode

                if (serType == null) {
                    serType = prop.getPropertyType();
                }
                ser = provider.findValueSerializer(serType, prop);
            }
            JsonNode schemaNode = (ser instanceof SchemaAware) ?
                    ((SchemaAware) ser).getSchema(provider, hint) :
                    JsonSchema.getDefaultSchemaNode();
            propertiesNode.put(prop.getName(), schemaNode);
        }
        o.put("properties", propertiesNode);
View Full Code Here

Examples of com.facebook.presto.jdbc.internal.jackson.databind.JsonNode

    @Override
    public JsonNode path(String fieldName)
    {
        if (_children != null) {
            JsonNode n = _children.get(fieldName);
            if (n != null) {
                return n;
            }
        }
        return MissingNode.getInstance();
View Full Code Here

Examples of com.fasterxml.jackson.databind.JsonNode

     * @param root node
     * @throws java.lang.IllegalStateException if vehicle id is missing OR if neither start location id nor start location
     * coordinate are set
     */
    private void parse_vehicles(JsonNode root) {
        JsonNode vehicles = root.path(JsonConstants.VEHICLES);
        for(JsonNode vehicleNode : vehicles){
            //vehicle id
            JsonNode vehicle_id_node = vehicleNode.path(JsonConstants.Vehicle.ID);
            if(vehicle_id_node.isMissingNode()) throw new IllegalStateException("vehicle id missing");
            VehicleImpl.Builder vehicleBuilder = VehicleImpl.Builder.newInstance(vehicle_id_node.asText());
            //vehicle type
            VehicleType type = vehicle_type_map.get(vehicleNode.path(JsonConstants.Vehicle.TYPE_ID).asText());
            vehicleBuilder.setType(type);
            //earliest start
            JsonNode earliestStartNode = vehicleNode.path(JsonConstants.Vehicle.EARLIEST_START);
            if(!earliestStartNode.isMissingNode()) vehicleBuilder.setEarliestStart(earliestStartNode.asDouble());
            //latest end
            JsonNode latestEndNode = vehicleNode.path(JsonConstants.Vehicle.LATEST_END);
            if(!latestEndNode.isMissingNode()) vehicleBuilder.setLatestArrival(latestEndNode.asDouble());
            //start
                //location id
            boolean either_id_or_coord = false;
            JsonNode startAddressId = vehicleNode.path(JsonConstants.Vehicle.START_ADDRESS).path(JsonConstants.Address.ID);
            if(!startAddressId.isMissingNode()){
                vehicleBuilder.setStartLocationId(startAddressId.asText());
                either_id_or_coord = true;
            }
                //location coordinate
            {
                JsonNode lonNode = vehicleNode.path(JsonConstants.Vehicle.START_ADDRESS).path(JsonConstants.Address.LON);
                JsonNode latNode = vehicleNode.path(JsonConstants.Vehicle.START_ADDRESS).path(JsonConstants.Address.LAT);
                if (!lonNode.isMissingNode() && !latNode.isMissingNode()) {
                    vehicleBuilder.setStartLocationCoordinate(Coordinate.newInstance(lonNode.asDouble(), latNode.asDouble()));
                    either_id_or_coord = true;
                }
            }
            if(!either_id_or_coord) throw new IllegalStateException("start location of vehicle missing. either id or coordinate required");
            //end
                //location id
            JsonNode endAddressId = vehicleNode.path(JsonConstants.Vehicle.END_ADDRESS).path(JsonConstants.Address.ID);
            if(!endAddressId.isMissingNode()){
                if(!startAddressId.asText().equals(endAddressId.asText())){
                    vehicleBuilder.setEndLocationId(endAddressId.asText());
                }
            }
                //location coordinate
            {
                JsonNode lonNode = vehicleNode.path(JsonConstants.Vehicle.END_ADDRESS).path(JsonConstants.Address.LON);
                JsonNode latNode = vehicleNode.path(JsonConstants.Vehicle.END_ADDRESS).path(JsonConstants.Address.LAT);
                if (!lonNode.isMissingNode() && !latNode.isMissingNode()) {
                    vehicleBuilder.setEndLocationCoordinate(Coordinate.newInstance(lonNode.asDouble(), latNode.asDouble()));
                }
            }
            //skills
            JsonNode skillsNode = vehicleNode.path(JsonConstants.Vehicle.SKILLS);
            for(JsonNode skillNode : skillsNode){
                String skill = skillNode.asText();
                vehicleBuilder.addSkill(skill);
            }

View Full Code Here

Examples of com.gistlabs.mechanize.document.json.node.JsonNode

   *
   * @param var maybe null if not found
   * @return
   */
  protected Object lookupWalkForVar(String var) {
    JsonNode current = node;
    while (current!=null) {
      Object result = lookupVar(current, var);
      if (result!=null) return result;
     
      if (current.hasAttribute("inheritProperties")) {
        current = current.getParent();       
      } else {
        current = null;
      }
    }
    return lookupVar(node, var);
View Full Code Here

Examples of com.gistlabs.mechanize.document.json.node.JsonNode

  protected List<JsonNode> factory(final String key) {
    try {
      ArrayList<JsonNode> result = new ArrayList<JsonNode>();
      try {
        JsonNode n = factory(this.obj, key);
        if (n!=null)
          result.add(n);
      } catch(JsonArrayException e) {
        if (e.getArray()==null)
          throw e;
View Full Code Here

Examples of com.gistlabs.mechanize.document.json.node.JsonNode

      for (JsonNode child : children) {
        result.add(child.getValue());
      }
      return result;
    } else if (children.size()==1) {
      JsonNode child = children.get(0);
      List<String> attributeNames = child.getAttributeNames();
      Collections.sort(attributeNames);

      if (attributeNames.size()==0) { // treat child as the attribute value
        return child.getValue();
      } else { // treat child as object with map values
        Map<String, String> result = new LinkedHashMap<String, String>();
        for (String attrName : attributeNames) {
          result.put(attrName, child.getAttribute(attrName));
        }
        return result;
      }
    } else { // return null
      return null;
View Full Code Here

Examples of com.google.appengine.repackaged.org.codehaus.jackson.JsonNode

        return war;
    }

    protected void assertResponse(Map<String, String> expected, String actual) throws Exception {
        ObjectMapper mapper = new ObjectMapper();
        JsonNode root = mapper.readTree(actual);
        for (Map.Entry<String, String> entry : expected.entrySet()) {
            Assert.assertEquals(entry.getValue(), root.get(entry.getKey()).asText());
        }
    }
View Full Code Here

Examples of com.mashape.unirest.http.JsonNode

    assertTrue(jsonResponse.getHeaders().size() > 0);
    assertTrue(jsonResponse.getBody().toString().length() > 0);
    assertFalse(jsonResponse.getRawBody() == null);
    assertEquals(200, jsonResponse.getStatus());
   
    JsonNode json = jsonResponse.getBody();
    assertFalse(json.isArray());
    assertNotNull(json.getObject());
    assertNotNull(json.getArray());
    assertEquals(1, json.getArray().length());
    assertNotNull(json.getArray().get(0));
  }
View Full Code Here

Examples of org.codehaus.jackson.JsonNode

        Exception,
        JsonParseException,
        JsonMappingException {

        // read the response
        JsonNode response = mapper.readTree(ips);

        // bail on invalid response
        if (!response.isObject()) {
            throw new Exception("Invalid JSON-RPC response");
        }
        ObjectNode jsonObject = ObjectNode.class.cast(response);

        // detect errors
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.