@Override public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { return canReadOrWrite(type); }
private String getJsonpFunctionName() { UriInfo uriInfo = getUriInfo(); if (uriInfo == null) { return null; } MultivaluedMap<String, String> queryParameters = uriInfo.getQueryParameters(); if (queryParameters == null) { return null; } return queryParameters.getFirst("jsonp"); }
JsonMapper jsonMapper = new JsonMapper(new ObjectMapper()); jsonMapper.readFrom(Object.class, Object.class, null, null, null, new InputStream()
if (isPrettyPrintRequested()) { jsonGenerator.useDefaultPrettyPrinter(); String jsonpFunctionName = getJsonpFunctionName(); if (jsonpFunctionName != null) { value = new JSONPObject(jsonpFunctionName, value, rootType);
private void assertRoundTrip(String value) throws IOException { JsonCodec<String> jsonCodec = JsonCodec.jsonCodec(String.class); JsonMapper jsonMapper = new JsonMapper(new ObjectMapper()); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); MultivaluedMap<String, Object> headers = new GuavaMultivaluedMap<>(); jsonMapper.writeTo(value, String.class, null, null, null, headers, outputStream); String json = new String(outputStream.toByteArray(), UTF_8); assertTrue(!json.contains("<")); assertTrue(!json.contains(">")); assertTrue(!json.contains("'")); assertTrue(!json.contains("&")); assertEquals(jsonCodec.fromJson(json), value); assertEquals(headers.getFirst(HttpHeaders.X_CONTENT_TYPE_OPTIONS), "nosniff"); }
JsonMapper jsonMapper = new JsonMapper(new ObjectMapper()); jsonMapper.readFrom(Object.class, Object.class, null, null, null, new InputStream()
if (isPrettyPrintRequested()) { jsonGenerator.useDefaultPrettyPrinter(); String jsonpFunctionName = getJsonpFunctionName(); if (jsonpFunctionName != null) { value = new JSONPObject(jsonpFunctionName, value, rootType);
JsonMapper jsonMapper = new JsonMapper(new ObjectMapper()); jsonMapper.readFrom(Object.class, Object.class, null, null, null, new InputStream()
@Override public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { return canReadOrWrite(type); }
private String getJsonpFunctionName() { UriInfo uriInfo = getUriInfo(); if (uriInfo == null) { return null; } MultivaluedMap<String, String> queryParameters = uriInfo.getQueryParameters(); if (queryParameters == null) { return null; } return queryParameters.getFirst("jsonp"); }
@Override public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { return canReadOrWrite(type); }
private boolean isPrettyPrintRequested() { UriInfo uriInfo = getUriInfo(); if (uriInfo == null) { return false; } MultivaluedMap<String, String> queryParameters = uriInfo.getQueryParameters(); return queryParameters != null && queryParameters.containsKey("pretty"); }
@Override public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { return canReadOrWrite(type); }
private boolean isPrettyPrintRequested() { UriInfo uriInfo = getUriInfo(); if (uriInfo == null) { return false; } MultivaluedMap<String, String> queryParameters = uriInfo.getQueryParameters(); return queryParameters != null && queryParameters.containsKey("pretty"); }