Package org.codehaus.jackson.node

Examples of org.codehaus.jackson.node.ArrayNode


    System.out.println("we got " + prefix);
    //ArrayList<String> words = pt.t.returnFullWordMatches(prefix);
    ArrayList<String> words = t.returnFullWordMatches(prefix);
    ObjectMapper mapper = new ObjectMapper();
    JsonNode rootNode = mapper.createObjectNode(); // will be of type ObjectNode
    ArrayNode an = ((ObjectNode)rootNode).putArray("firstName");
    int i = 0;
    for (String word : words) {
      an.insert(i++, word);
    }
    //return prefix + " that's what I got";
    return rootNode.toString();
   }
View Full Code Here


//      e1.printStackTrace();
//    }
    // Gets a record given id parameter and returns corresponding JSON records
    ObjectMapper mapper = new ObjectMapper();
    JsonNode rootNode = mapper.createObjectNode(); // will be of type ObjectNode
    ArrayNode jSONrecords = ((ObjectNode)rootNode).putArray("ProgramRecord");
 
    try {
      Connection conn = null;
      DriverManager.registerDriver(new AppEngineDriver());
      conn = DriverManager.getConnection("jdbc:google:rdbms://pcni.org:openhmis:openciss/compass");
      String stmt = "SELECT program_key, program_name, agency_name, program_type, site_geocode, target_pop_a_name, update_time_stamp, units_total, units_available, units_occupied, contact_name, contact_phone, program_address, program_city, program_zip, program_address_full FROM compass.program_profile_info WHERE program_key=?";
      PreparedStatement pstmt = (PreparedStatement)conn.prepareStatement(stmt);
//      try {
//        System.out.println("value=[" + idStr + "]; bytes=" + Arrays.toString(idStr.getBytes("UTF-8")));
//      } catch (UnsupportedEncodingException e) {
//        e.printStackTrace();
//      }
      pstmt.setString(1, id);
      //pstmt.setString(1, "3459");
      pstmt.toString();
      ResultSet rs = pstmt.executeQuery();
      int i = 0;
      while (rs.next()) {
        JsonNode recordNode = mapper.createObjectNode(); // will be of type ObjectNode
        ((ObjectNode)recordNode).put("ProgramKey", rs.getString("program_key"));
        ((ObjectNode)recordNode).put("ProgramName", rs.getString("program_name"));
        ((ObjectNode)recordNode).put("AgencyName", rs.getString("agency_name"));
        ((ObjectNode)recordNode).put("ProgramType", rs.getString("program_type"));
        ((ObjectNode)recordNode).put("SiteGeocode", rs.getString("site_geocode"));
        ((ObjectNode)recordNode).put("TargetPopAName", rs.getString("target_pop_a_name"));
        ((ObjectNode)recordNode).put("UpdateTimeStamp", rs.getString("update_time_stamp"));
        ((ObjectNode)recordNode).put("UnitsTotal", rs.getString("units_total"));
        ((ObjectNode)recordNode).put("UnitsAvailable", rs.getString("units_available"));
        ((ObjectNode)recordNode).put("UnitsOccupied", rs.getString("units_occupied"));
        ((ObjectNode)recordNode).put("ContactName", rs.getString("contact_name"));
        ((ObjectNode)recordNode).put("ContactPhone", rs.getString("contact_phone"));
        ((ObjectNode)recordNode).put("ProgramAddress", rs.getString("program_address"));
        ((ObjectNode)recordNode).put("ProgramCity", rs.getString("program_city"));
        ((ObjectNode)recordNode).put("ProgramZip", rs.getString("program_zip"));
        ((ObjectNode)recordNode).put("ProgramAddressFull", rs.getString("program_address_full"));
        jSONrecords.insert(i++, recordNode);
      }
      conn.close();
      return rootNode.toString();
    }
    catch (SQLException e) {
View Full Code Here

    //ArrayList<String> words = pt.t.returnFullWordMatches(prefix);
    ArrayList<String> words = t.returnFullWordMatches(prefix);
    System.out.println("we got " + prefix);
    ObjectMapper mapper = new ObjectMapper();
    JsonNode rootNode = mapper.createObjectNode(); // will be of type ObjectNode
    ArrayNode an = ((ObjectNode)rootNode).putArray("lastName");
    int i = 0;
    for (String word : words) {
      an.insert(i++, word);
    }
    return rootNode.toString();
   }
View Full Code Here

        method = req.get("method").getTextValue();
        id = req.get("id");
        JsonNode args = req.get("params");
        if (args instanceof ArrayNode) {
            // Positional parameters
            ArrayNode array = (ArrayNode)args;
            params = new Object[array.size()];
            for (int i = 0; i < params.length; i++) {
                params[i] = array.get(i);
            }
        } else if (args == null) {
            params = new Object[0];
        } else {
            throw new IllegalArgumentException("Invalid request: params is not a JSON array - " + args);
View Full Code Here

            root = JacksonHelper.MAPPER.readTree(request.getReader());
        }

        try {
            if (root.isArray()) {
                ArrayNode input = (ArrayNode)root;
                JsonRpc20BatchRequest batchReq = new JsonRpc20BatchRequest(input);
                for (int i = 0; i < batchReq.getRequests().size(); i++) {
                    JsonRpcResponse result = batchReq.getBatchResponse().getResponses().get(i);
                    if (result == null) {
                        result = invoke(batchReq.getRequests().get(i));
                        batchReq.getBatchResponse().getResponses().set(i, result);
                    }
                }
                ArrayNode responses = batchReq.getBatchResponse().toJSONArray();
                JacksonHelper.MAPPER.writeValue(response.getWriter(), responses);
            } else {
                if (root.has("jsonrpc")) {
                    JsonRpc20Request jsonReq = new JsonRpc20Request((ObjectNode)root);
                    JsonRpcResponse jsonResult = invoke(jsonReq);
View Full Code Here

    public List<JsonRpcResponse> getResponses() {
        return results;
    }

    public ArrayNode toJSONArray() {
        ArrayNode jsonArray = JsonNodeFactory.instance.arrayNode();
        for (JsonRpcResponse result : results) {
            jsonArray.add(result.getJsonNode());
        }
        return jsonArray;
    }
View Full Code Here

        this.params = params;
        ObjectNode req = JsonNodeFactory.instance.objectNode();
        req.put("method", method);
        req.put("id", id);
        if (params != null) {
            ArrayNode args = JsonNodeFactory.instance.arrayNode();
            for (Object p : params) {
                args.add(JsonNodeFactory.instance.POJONode(p));
            }
            req.put("params", args);
        }
        this.jsonNode = req;
    }
View Full Code Here

            id = idNode;
        }
        JsonNode args = req.get("params");
        if (args instanceof ArrayNode) {
            // Positional parameters
            ArrayNode array = (ArrayNode)args;
            params = new Object[array.size()];
            for (int i = 0; i < params.length; i++) {
                params[i] = array.get(i);
            }
        } else if (args instanceof ObjectNode) {
            ObjectNode map = (ObjectNode)args;
            mappedParams = map;
            params = null;
View Full Code Here

        return JsonRelation.class.isAssignableFrom(o.getClass());
    }

    @Override
    public Set<String> getEntityDiscriminators(ObjectNode jsonNodes) {
        ArrayNode typesNode = (ArrayNode) jsonNodes.get(TYPES_PROPERTY);
        Set<String> discriminators = new HashSet<>();
        for (JsonNode jsonNode : typesNode) {
            discriminators.add(jsonNode.getTextValue());
        }
View Full Code Here

    }

    @Override
    public ObjectNode createEntity(TypeMetadataSet<EntityTypeMetadata<JsonNodeMetadata>> types, Set<String> discriminators) {
        ObjectNode rootNode = mapper.createObjectNode();
        ArrayNode typesNode = mapper.createArrayNode();
        for (String typeName : discriminators) {
            typesNode.add(typeName);
        }
        rootNode.put(TYPES_PROPERTY, typesNode);
        UUID uuid = UUID.randomUUID();
        rootNode.put(ID_PROPERTY, uuid.toString());
        return rootNode;
View Full Code Here

TOP

Related Classes of org.codehaus.jackson.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.