List of usage examples for org.springframework.integration.mapping.support JsonHeaders TYPE_ID
String TYPE_ID
To view the source code for org.springframework.integration.mapping.support JsonHeaders TYPE_ID.
Click Source Link
From source file:org.springframework.integration.support.json.BoonJsonObjectMapper.java
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public <T> T fromJson(Object json, Map<String, Object> javaTypes) throws Exception {
JsonParserAndMapper parser = this.objectMapper.parser();
Class<?> classType = this.createJavaType(javaTypes, JsonHeaders.TYPE_ID);
Class<?> contentClassType = this.createJavaType(javaTypes, JsonHeaders.CONTENT_TYPE_ID);
Class<?> keyClassType = this.createJavaType(javaTypes, JsonHeaders.KEY_TYPE_ID);
if (keyClassType != null) {
logger.warn("Boon doesn't support the Map 'key' conversion. Will be returned raw Map<String, Object>");
if (json instanceof String) {
return (T) parser.parseMap((String) json);
} else if (json instanceof byte[]) {
return (T) parser.parseMap((byte[]) json);
} else if (json instanceof char[]) {
return (T) parser.parseMap((char[]) json);
} else if (json instanceof File) {
return (T) parser.parseMap(new FileReader((File) json));
} else if (json instanceof InputStream) {
return (T) parser.parseMap((InputStream) json);
} else if (json instanceof Reader) {
return (T) parser.parseMap((Reader) json);
} else {/*from w w w .j a v a 2s .com*/
throw new IllegalArgumentException("'json' argument must be an instance of: " + supportedJsonTypes
+ " , but gotten: " + json.getClass());
}
}
if (contentClassType != null) {
if (json instanceof String) {
return (T) this.objectMapper.readValue((String) json, (Class<Collection>) classType,
contentClassType);
} else if (json instanceof byte[]) {
return (T) this.objectMapper.readValue((byte[]) json, (Class<Collection>) classType,
contentClassType);
} else if (json instanceof char[]) {
return (T) this.objectMapper.readValue((char[]) json, (Class<Collection>) classType,
contentClassType);
} else if (json instanceof File) {
return (T) this.objectMapper.readValue((File) json, (Class<Collection>) classType,
contentClassType);
} else if (json instanceof InputStream) {
return (T) this.objectMapper.readValue((InputStream) json, (Class<Collection>) classType,
contentClassType);
} else if (json instanceof Reader) {
return (T) this.objectMapper.readValue((Reader) json, (Class<Collection>) classType,
contentClassType);
} else {
throw new IllegalArgumentException("'json' argument must be an instance of: " + supportedJsonTypes
+ " , but gotten: " + json.getClass());
}
}
return (T) fromJson(json, classType);
}