Java Code Examples for com.fasterxml.jackson.databind.JsonNode#getClass()
The following examples show how to use
com.fasterxml.jackson.databind.JsonNode#getClass() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: YAMLHelper.java From incubator-taverna-language with Apache License 2.0 | 6 votes |
/** * This method is used for extracting the Formats of a CWL input or Output * Single argument(Input or Output) can have multiple Formats. * * @param input * Single CWL input or output as a JsonNode * @param detail * respective PortDetail Object to hold the extracted Label */ public void extractFormat(JsonNode input, PortDetail detail) { if (input != null) if (input.has(FORMAT)) { JsonNode formatInfo = input.get(FORMAT); ArrayList<String> format = new ArrayList<>(); detail.setFormat(format); if (formatInfo.getClass() == TextNode.class) { figureOutFormats(formatInfo.asText(), detail); } else if (formatInfo.getClass() == ArrayNode.class) { for (JsonNode eachFormat : formatInfo) { figureOutFormats(eachFormat.asText(), detail); } } } }
Example 2
Source File: JsonNodeSerde.java From football-events with MIT License | 5 votes |
@Override public byte[] serialize(String topic, JsonNode data) { try { return mapper.writeValueAsBytes(data); } catch (Exception e) { throw new SerializationException("Error serializing " + data.getClass() + " " + data, e); } }
Example 3
Source File: GuicePropertyFilteringMessageBodyWriter.java From Singularity with Apache License 2.0 | 4 votes |
@Override public void writeTo( final Object o, final Class<?> type, final Type genericType, final Annotation[] annotations, final MediaType mediaType, final MultivaluedMap<String, Object> httpHeaders, final OutputStream os ) throws IOException { final PropertyFiltering annotation = findPropertyFiltering(annotations); final PropertyFilter propertyFilter = new PropertyFilter( Optional .ofNullable(uriInfo.getQueryParameters().get(annotation.using())) .orElse(Collections.<String>emptyList()) ); if (!propertyFilter.hasFilters()) { super.writeTo(o, type, genericType, annotations, mediaType, httpHeaders, os); return; } final Timer timer = getTimer(); final Timer.Context context = timer.time(); try { final JsonNode tree = objectMapper.valueToTree(o); propertyFilter.filter(tree); super.writeTo( tree, tree.getClass(), tree.getClass(), annotations, mediaType, httpHeaders, os ); } finally { context.stop(); } }