List of usage examples for com.fasterxml.jackson.databind ObjectMapper getVisibilityChecker
public VisibilityChecker<?> getVisibilityChecker()
From source file:de.fau.cs.inf2.tree.evaluation.TreeEvalIO.java
public static ObjectMapper createJSONMapper(final DataFormat format) { final ObjectMapper mapper; {/*from w ww.j a v a2s .c o m*/ switch (format) { case FORMAT_JSON: { mapper = new ObjectMapper(); break; } default: { assert (false); return null; } } } // configure mapper { mapper.enable(SerializationFeature.INDENT_OUTPUT); mapper.setVisibilityChecker(mapper.getVisibilityChecker().with(JsonAutoDetect.Visibility.NONE)); mapper.setSerializationInclusion(Include.NON_NULL); DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.S"); mapper.setDateFormat(df); addMixIns(mapper, TimeSummary.class, MixInTimeSummary.class); addMixIns(mapper, DiffSummary.class, MixInDiffSummary.class); addMixIns(mapper, TreeMatcherTypeEnum.class, MixInTreeMatcherTypeEnum.class); addMixIns(mapper, PsoResult.class, MixInPSOResult.class); addMixIns(mapper, ValidationDecision.class, MixInValidationDecision.class); addMixIns(mapper, ValidationDecisionList.class, MixInValidationDecisionList.class); addMixIns(mapper, ValidationEntry.class, MixInValidationEntry.class); addMixIns(mapper, ValidationEnum.class, MixInValidationEnum.class); addMixIns(mapper, ValidationRating.class, MixInValidationRating.class); addMixIns(mapper, ValidationInputSummary.class, MixInValidationInputSummary.class); addMixIns(mapper, ValidationInfo.class, MixInValidationInfo.class); } return mapper; }
From source file:com.samlikescode.sandbox.jackson.mixin.MixinTest.java
@Test public void mixinTest() throws Exception { ObjectMapper om = new ObjectMapper(); om.setVisibilityChecker(om.getVisibilityChecker().with(JsonAutoDetect.Visibility.NONE)); om.addMixIn(Person.class, PersonMixin.class); // om.readValue() System.out.println(om.writeValueAsString(testPerson)); }
From source file:org.gameontext.mediator.JsonProvider.java
public JsonProvider() { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.setVisibilityChecker(/*from w w w . j ava 2 s.com*/ objectMapper.getVisibilityChecker().withFieldVisibility(JsonAutoDetect.Visibility.ANY)); setMapper(objectMapper); }
From source file:org.springframework.security.jackson2.AbstractMixinTests.java
protected ObjectMapper buildObjectMapper() { ObjectMapper mapper = new ObjectMapper().enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);//w ww .j av a 2s. c om mapper.setVisibilityChecker(mapper.getVisibilityChecker().withVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY)); return mapper; }
From source file:org.jsonschema2pojo.integration.MediaIT.java
@Test public void shouldRoundTripQuotedPrintableFieldWithNoFieldVisibility() throws Exception { ObjectMapper mapper = new ObjectMapper(); mapper.setVisibilityChecker(mapper.getVisibilityChecker().withFieldVisibility(Visibility.NONE)); roundTripAssertions(new ObjectMapper(), "anyBinaryEncoding", "\"=E3=82=A8=E3=83=B3=E3=82=B3=E3=83=BC=E3=83=89=E3=81=95=E3=82=8C=E3=81=9F=E6=96=87=E5=AD=97=E5=88=97\" is Japanese for \"encoded string\"", "\"??\" is Japanese for \"encoded string\"".getBytes("UTF-8")); }
From source file:org.saiku.web.rest.resources.FilterRepositoryResource.java
/** * Save filter//from w w w . ja v a 2 s .c om * @summary Save Filter. * @param filterJSON The Filter JSON object. * @return A response containing the filter. */ @POST @Produces({ "application/json" }) @Path("/{filtername}") @ReturnType("org.saiku.olap.dto.filter.SaikuFilter") public Response saveFilter(@FormParam("filter") String filterJSON) { try { ObjectMapper mapper = new ObjectMapper(); mapper.setVisibilityChecker( mapper.getVisibilityChecker().withFieldVisibility(JsonAutoDetect.Visibility.ANY)); SaikuFilter filter = mapper.readValue(filterJSON, SaikuFilter.class); String username = sessionService.getAllSessionObjects().get("username").toString(); filter.setOwner(username); Map<String, SaikuFilter> filters = getFiltersInternal(); filters.put(filter.getName(), filter); return Response.ok(filter).build(); } catch (Exception e) { log.error("Cannot save filter (" + filterJSON + ")", e); String error = ExceptionUtils.getRootCauseMessage(e); return Response.serverError().entity(error).build(); } }
From source file:org.saiku.web.rest.resources.QueryResource.java
@PUT
@Produces({ "application/json" })
@Path("/{queryname}/tag")
public Status activateTag(@PathParam("queryname") String queryName, @FormParam("tag") String tagJSON) {
if (log.isDebugEnabled()) {
log.debug("TRACK\t" + "\t/query/" + queryName + "/tags\tPUT");
}/*from w w w . j av a 2 s. co m*/
try {
ObjectMapper mapper = new ObjectMapper();
mapper.setVisibilityChecker(mapper.getVisibilityChecker().withFieldVisibility(Visibility.ANY));
SaikuTag tag = mapper.readValue(tagJSON, SaikuTag.class);
olapQueryService.setTag(queryName, tag);
return Status.OK;
} catch (Exception e) {
log.error("Cannot add tag " + tagJSON + " for query (" + queryName + ")", e);
}
return Status.INTERNAL_SERVER_ERROR;
}
From source file:org.saiku.web.rest.resources.QueryResource.java
@PUT
@Produces({ "application/json" })
@Path("/{queryname}/filter")
public Response activateFilter(@PathParam("queryname") String queryName,
@FormParam("filter") String filterJSON) {
if (log.isDebugEnabled()) {
log.debug("TRACK\t" + "\t/query/" + queryName + "/tags\tPUT");
}//from w w w . j a v a 2 s. com
try {
ObjectMapper mapper = new ObjectMapper();
mapper.setVisibilityChecker(mapper.getVisibilityChecker().withFieldVisibility(Visibility.ANY));
SaikuFilter filter = mapper.readValue(filterJSON, SaikuFilter.class);
SaikuQuery sq = olapQueryService.applyFilter(queryName, filter);
return Response.ok(sq).build();
} catch (Exception e) {
log.error("Cannot activate filter for query (" + queryName + "), json:" + filterJSON, e);
String error = ExceptionUtils.getRootCauseMessage(e);
return Response.serverError().entity(error).build();
}
}