List of usage examples for com.fasterxml.jackson.databind ObjectMapper ObjectMapper
public ObjectMapper()
From source file:io.fabric8.kubernetes.pipeline.devops.elasticsearch.JsonUtils.java
public static ObjectMapper createObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); return mapper; }
From source file:com.mgatelabs.bytemapper.support.definitions.FormatDefinition.java
public static FormatDefinition load(File input) throws Exception { ObjectMapper mapper = new ObjectMapper(); FormatDefinition def;//from w ww .j ava2s. c om def = mapper.readValue(input, FormatDefinition.class); def.sanity(); return def; }
From source file:io.klerch.alexa.state.utils.ConversionUtils.java
/** * A json-string of key-value pairs is read out as a map * @param json json-string of key-value pairs * @return a map with corresponding key-value paris *//* w w w .ja v a2s . c o m*/ public static Map<String, Object> mapJson(final String json) { final ObjectMapper mapper = new ObjectMapper(); if (json == null || json.isEmpty()) { return new HashMap<>(); } final TypeReference<HashMap<String, Object>> typeRef = new TypeReference<HashMap<String, Object>>() { }; try { // read jsonString into map return mapper.readValue(json, typeRef); } catch (IOException e) { log.error(e); return new HashMap<>(); } }
From source file:cn.dataprocess.cfzk.JsonUtil.java
public static <K> K toJavaBean(String content, Class<K> valueType) throws IOException { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(DeserializationFeature.FAIL_ON_UNRESOLVED_OBJECT_IDS, false); mapper.configure(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES, false); K ret = mapper.readValue(content, valueType); mapper = null;//from www . j av a2 s . co m return ret; }
From source file:com.pacoworks.cardframework.api.factories.system.SystemFactory.java
public static BasePhaseSystem create(CardgameFramework.CardgameFrameworkComponent injector, @NonNull URL filePath) throws IOException { ObjectMapper mapper = new ObjectMapper(); CFWSystem cfwSystem = mapper.readValue(filePath, CFWSystem.class); return create(injector, cfwSystem); }
From source file:edu.ub.ir.oof1.Util.JSONUtil.java
public static String newsResultsToJson(NewsResults _news_results) { String out = ""; try {//from w w w .j a va 2 s . c om ObjectMapper mapper = new ObjectMapper(); out = mapper.writeValueAsString(_news_results); } catch (Exception e) { e.printStackTrace(); } return out; }
From source file:org.teavm.flavour.json.test.JSONRunner.java
public static JsonNode serialize(Object value) { return new ObjectMapper().valueToTree(value); }
From source file:com.basistech.rosette.dm.json.plain.AdmAssert.java
public static ObjectMapper objectMapper() { return AnnotatedDataModelModule.setupObjectMapper(new ObjectMapper()); }
From source file:com.github.tomakehurst.wiremock.common.Json.java
public static <T> T read(String json, Class<T> clazz) { try {//ww w . j ava 2 s. com ObjectMapper mapper = new ObjectMapper(); mapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true); return mapper.readValue(json, clazz); } catch (IOException ioe) { throw new RuntimeException( "Unable to bind JSON to object. Reason: " + ioe.getMessage() + " JSON:" + json, ioe); } }
From source file:facturacion.restClient.EmpresaRest.java
public static Empresa GetEmpresaDetail(String empresa) { try {/*from w w w . ja v a 2 s .c o m*/ Empresa e = new Empresa(); ObjectMapper mapper = new ObjectMapper(); System.out.println("empresa=" + empresa); WebTarget webTarget = Uri.uriEmpresaDetail(empresa); Invocation.Builder invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON); invocationBuilder.header("some-header", "true"); Response response = invocationBuilder.get(); int in = response.getStatus(); System.out.println("status=" + in); if (in == 200) { String cad = response.readEntity(String.class); e = mapper.readValue(cad, Empresa.class); System.out.println("FULLLLLLLLL"); } else { e = null; System.out.println("EMPTYYYYYYYYy"); } return e; //return (response.getStatus() == 200) ? mapper.readValue(response.readEntity(String.class),Empresa.class) : null; } catch (UnrecognizedPropertyException e) { System.out.println("error en los datooooos de mapeo de la URI"); return null; } catch (ProcessingException e) { System.out.println("Error no se pudo conectar a la URI"); return null; } catch (JsonGenerationException e) { System.out.println("---===> 1"); e.printStackTrace(); return null; } catch (JsonMappingException e) { System.out.println("---===> 2"); e.printStackTrace(); return null; } catch (Exception e) { System.out.println("---===> 3"); e.printStackTrace(); return null; } }