List of usage examples for com.fasterxml.jackson.datatype.jdk8 Jdk8Module Jdk8Module
Jdk8Module
From source file:io.airlift.json.ObjectMapperProvider.java
public ObjectMapperProvider() { modules.add(new Jdk7Module()); modules.add(new Jdk8Module()); modules.add(new JSR310Module()); modules.add(new GuavaModule()); modules.add(new JodaModule()); }
From source file:io.syndesis.model.integration.StepDeserializerTest.java
private <T extends Step> T readTestFilter(String resource) throws java.io.IOException { return (T) new ObjectMapper().registerModule(new Jdk8Module()) .readValue(this.getClass().getResourceAsStream(resource), Step.class); }
From source file:io.github.retz.cli.CommandGetApp.java
@Override public int handle(ClientCLIConfig fileConfig, boolean verbose) throws Throwable { LOG.debug("Configuration: {}", fileConfig.toString()); try (Client webClient = Client.newBuilder(fileConfig.getUri()) .setAuthenticator(fileConfig.getAuthenticator()).checkCert(!fileConfig.insecure()) .setVerboseLog(verbose).build()) { Response res = webClient.getApp(appName); if (res instanceof ErrorResponse) { LOG.error(res.status());/*from ww w . j av a 2 s. c o m*/ } else if (res instanceof GetAppResponse) { GetAppResponse getAppResponse = (GetAppResponse) res; Application app = getAppResponse.application(); ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new Jdk8Module()); mapper.writeValue(System.out, app); System.out.println(); return 0; } } return -1; }
From source file:io.github.retz.web.WebConsoleTest.java
/** * Initializes the test.//from w w w . ja v a 2s .co m * * @throws Exception if some errors were occurred */ @Before public void setUp() throws Exception { Protos.FrameworkInfo frameworkInfo = Protos.FrameworkInfo.newBuilder().setUser("") .setName(RetzScheduler.FRAMEWORK_NAME).build(); InputStream in = MesosFrameworkLauncher.class.getResourceAsStream("/retz.properties"); MesosFrameworkLauncher.Configuration conf = new MesosFrameworkLauncher.Configuration( new FileConfiguration(in)); mapper = new ObjectMapper(); mapper.registerModule(new Jdk8Module()); RetzScheduler scheduler = new RetzScheduler(conf, frameworkInfo); webConsole = new WebConsole(24301); WebConsole.setScheduler(scheduler); awaitInitialization(); webClient = new Client("ws://localhost:24301/cui"); }
From source file:com.orange.ngsi2.model.EntityTest.java
@Test public void deserializationEntityTest() throws IOException { String jsonString = "{\n" + " \"id\" : \"Bcn-Welt\",\n" + " \"type\" : \"Room\",\n" + " \"temperature\" : {\n" + " \"value\" : 21.7\n" + " },\n" + " \"humidity\" : {\n" + " \"value\" : 60\n" + " }\n" + "}"; ObjectMapper objectMapper = new ObjectMapper().registerModule(new Jdk8Module()); Entity entity = objectMapper.readValue(jsonString, Entity.class); Attribute temp = entity.getAttributes().get("temperature"); assertEquals(0, temp.getMetadata().size()); }
From source file:com.orange.ngsi2.model.EntityTypeTest.java
@Test public void deserializationEntityTypeTest() throws IOException { ObjectMapper objectMapper = new ObjectMapper().registerModule(new Jdk8Module()); EntityType entityType = objectMapper.readValue(jsonString, EntityType.class); assertEquals(7, entityType.getCount()); assertEquals(3, entityType.getAttrs().size()); assertTrue(entityType.getAttrs().containsKey("temperature")); assertTrue(entityType.getAttrs().containsKey("humidity")); assertTrue(entityType.getAttrs().containsKey("pressure")); assertEquals("urn:phenomenum:temperature", entityType.getAttrs().get("temperature").getType()); assertEquals("percentage", entityType.getAttrs().get("humidity").getType()); assertEquals("null", entityType.getAttrs().get("pressure").getType()); }
From source file:it.polimi.diceH2020.launcher.model.InteractiveExperiment.java
public void setSol(Solution sol) { ObjectMapper mapper = new ObjectMapper().registerModule(new Jdk8Module()) .enable(SerializationFeature.INDENT_OUTPUT); try {// ww w . ja v a 2 s . c o m this.finalSolution = Compressor.compress(mapper.writeValueAsString(sol)); } catch (IOException e) { this.finalSolution = "Error"; } }
From source file:it.polimi.diceH2020.SPACE4Cloud.shared.Test2.java
@Test public void test2() { Solution sol = SolutionGenerator.build(); try {// w w w. j a v a 2 s.c o m ObjectMapper mapper = new ObjectMapper().registerModule(new Jdk8Module()); String serialized = mapper.writeValueAsString(sol); System.out.println(serialized); Solution data2 = mapper.readValue(serialized, Solution.class); System.out.println(data2.toString()); System.out.println(data2.toStringReduced()); } catch (IOException e) { e.printStackTrace(); } }
From source file:io.github.retz.db.Database.java
Database() { MAPPER.registerModule(new Jdk8Module()); }
From source file:org.apache.james.mailbox.elasticsearch.json.MessageToElasticSearchJson.java
public MessageToElasticSearchJson(TextExtractor textExtractor, ZoneId zoneId, IndexAttachments indexAttachments, MessageSearchIndex.IndexMessageId indexMessageId) { this.textExtractor = textExtractor; this.zoneId = zoneId; this.indexAttachments = indexAttachments; this.mapper = new ObjectMapper(); this.mapper.registerModule(new GuavaModule()); this.mapper.registerModule(new Jdk8Module()); this.indexMessageId = indexMessageId; }