Package org.codehaus.jackson.map

Examples of org.codehaus.jackson.map.ObjectMapper.writeValueAsBytes()


  }
 
  public byte[] toJson() {
    ObjectMapper mapper = new ObjectMapper();
    try {
      return mapper.writeValueAsBytes(this);
    } catch (Exception e) {
      throw new SlabsException("Exception while serializing to json", e);
    }
  }
 
View Full Code Here


    byte[] data;
    try {
      ObjectNode databaseJson = doc.getDatabaseJson();
      databaseJson.put("_last_update", new Date().getTime());
      ObjectMapper mapper = new ObjectMapper();
      data = mapper.writeValueAsBytes(databaseJson);
    } catch (Exception e) {
      callback.callError(doc.getId(), e);
      return;
    }
   
View Full Code Here

                            insertStmt.setNull(3, Types.BLOB);
                        }
                        else
                        {
                            final Map<String, Object> attributes = configuredObject.getAttributes();
                            byte[] attributesAsBytes = objectMapper.writeValueAsBytes(attributes);
                            ByteArrayInputStream bis = new ByteArrayInputStream(attributesAsBytes);
                            insertStmt.setBinaryStream(3, bis, attributesAsBytes.length);
                        }
                        insertStmt.execute();
                    }
View Full Code Here

            try
            {
                for(Map.Entry<UUID, Map<String,Object>> bindingEntry : bindingsToUpdate.entrySet())
                {
                    stmt.setString(1, "Binding");
                    byte[] attributesAsBytes = objectMapper.writeValueAsBytes(bindingEntry.getValue());

                    ByteArrayInputStream bis = new ByteArrayInputStream(attributesAsBytes);
                    stmt.setBinaryStream(2, bis, attributesAsBytes.length);
                    stmt.setString(3, bindingEntry.getKey().toString());
                    stmt.execute();
View Full Code Here

                        else
                        {
                            final Map<String, Object> attributes = configuredObject.getAttributes();
                            final ObjectMapper objectMapper = new ObjectMapper();
                            objectMapper.registerModule(_module);
                            byte[] attributesAsBytes = objectMapper.writeValueAsBytes(attributes);

                            ByteArrayInputStream bis = new ByteArrayInputStream(attributesAsBytes);
                            insertStmt.setBinaryStream(3, bis, attributesAsBytes.length);
                        }
                        insertStmt.execute();
View Full Code Here

                    try
                    {
                        stmt2.setString(1, configuredObject.getType());
                        if (configuredObject.getAttributes() != null)
                        {
                            byte[] attributesAsBytes = objectMapper.writeValueAsBytes(
                                    configuredObject.getAttributes());
                            ByteArrayInputStream bis = new ByteArrayInputStream(attributesAsBytes);
                            stmt2.setBinaryStream(2, bis, attributesAsBytes.length);
                        }
                        else
View Full Code Here

    private byte[] getJsonPayload(Object ob) {
        ObjectMapper mapper = em.getObjectMapper();

        try {
            return mapper.writeValueAsBytes(ob);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

        }
        ObjectMapper mapper = new ObjectMapper();
        FSDataOutputStream out = null;
        fs = FileSystem.get(conf);
        out = fs.create(resultsPath);
        out.write(mapper.writeValueAsBytes(results));
        if (fs != null) {
            fs.close();
        }
        if (out != null) {
            out.close();
View Full Code Here

        }
        ObjectMapper mapper = new ObjectMapper();
        FSDataOutputStream out = null;
        fs = FileSystem.get(conf);
        out = fs.create(tagPath);
        out.write(mapper.writeValueAsBytes(tags));
        if (fs != null) {
            fs.close();
        }
        if (out != null) {
            out.close();
View Full Code Here

        ;
       
        final ObjectMapper jsonMapper = new ObjectMapper(jsonF);
        jsonMapper.registerModule(new com.fasterxml.jackson.module.afterburner.AfterburnerModule());

        byte[] json = jsonMapper.writeValueAsBytes(item);
        System.out.println("Warmed up: data size is "+json.length+" bytes; "+REPS+" reps -> "
                +((REPS * json.length) >> 10)+" kB per iteration");
        System.out.println();

        int round = 0;
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.