List of usage examples for com.fasterxml.jackson.databind ObjectMapper ObjectMapper
public ObjectMapper()
From source file:io.acme.solution.domain.util.MementoBuilder.java
public static String flatten(final HashMap<String, Object> attributesMap) { final ObjectMapper mapper = new ObjectMapper(); try {/*w w w . j av a2 s . c o m*/ return mapper.writeValueAsString(attributesMap); } catch (JsonProcessingException exception) { log.debug("Failed to craete memento object"); log.trace("Failed to create memento object for the passed attributes map", exception); return null; } }
From source file:com.basistech.rosette.api.AbstractTest.java
@BeforeClass public static void before() throws IOException { URL url = Resources.getResource("MockServerClientPort.property"); String clientPort = Resources.toString(url, Charsets.UTF_8); serverPort = Integer.parseInt(clientPort); mapper = ApiModelMixinModule.setupObjectMapper(new ObjectMapper()); }
From source file:com.cirro.jsonjoin.utils.FileManager.java
public static String convertToJsonString(Row row) throws IOException { return new ObjectMapper().writeValueAsString(row); }
From source file:com.mapr.data.sputnik.util.JsonUtils.java
public JsonUtils() { mapper = new ObjectMapper(); }
From source file:com.computationnode.Summator.java
@POST @Consumes(MediaType.APPLICATION_JSON)/* w ww . ja v a 2s . co m*/ @Produces(MediaType.APPLICATION_JSON) public Response sum(String inputValues) throws IOException { ObjectMapper mapper = new ObjectMapper(); String responseString = new String(); try { Double[] inputArray = mapper.readValue(inputValues, Double[].class); double result = 0; for (int i = 0; i < inputArray.length; ++i) { result += inputArray[i]; } responseString = "[" + result + "]"; } catch (IOException e) { return Response.serverError().entity(e.toString()).build(); } return Response.ok(responseString, MediaType.APPLICATION_JSON).build(); }
From source file:com.exalttech.trex.stateful.models.trexlatencyv2.FilterTrexLatencyV2ResponseUtil.java
/** * Filter Response to create PortProperty * * @return//from www . j a va2 s. co m */ public static List<PortProperty> filterPortPropertiesArray(String response) { JSONObject jObject = new JSONObject(response); JSONObject data = jObject.getJSONObject("data"); int numOfPorts = countNumberOfPorts(response); List<PortProperty> portProperty = new ArrayList<PortProperty>(); ObjectMapper mapper = new ObjectMapper(); for (int i = 0; i < numOfPorts; i++) { try { portProperty.add(mapper.readValue(data.getJSONObject("port-" + i).toString(), PortProperty.class)); } catch (Exception ex) { LOG.error("Error: ", ex); } } return portProperty; }
From source file:de.kaojo.chat.TextMessageEncoder.java
@Override public String encode(Message object) throws EncodeException { ObjectMapper mapper = new ObjectMapper(); try {/* www . j a va 2 s . co m*/ return mapper.writeValueAsString(object); } catch (JsonProcessingException ex) { Logger.getLogger(TextMessageEncoder.class.getName()).log(Level.SEVERE, null, ex); throw new EncodeException(object, "Could not encode Message", ex); } }
From source file:nl.talsmasoftware.enumerables.support.json.jackson2.EnumerableJackson2ModuleTest.java
static ObjectMapper mapperWith(Module module) { ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.registerModule(module);/*from w w w . java 2s .co m*/ return mapper; }
From source file:io.fouad.jtb.core.utils.JsonUtils.java
public static <T> T toJavaObject(String json, Class<T> clazz) throws IOException { ObjectMapper mapper = new ObjectMapper(); mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); return mapper.readValue(json, clazz); }
From source file:com.baxter.githubexplore.network.JacksonConverterFactory.java
/** Create an instance using a default {@link ObjectMapper} instance for conversion. */ public static JacksonConverterFactory create() { return create(new ObjectMapper()); }