本文整理匯總了Java中org.codehaus.jackson.map.DeserializationConfig類的典型用法代碼示例。如果您正苦於以下問題:Java DeserializationConfig類的具體用法?Java DeserializationConfig怎麽用?Java DeserializationConfig使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DeserializationConfig類屬於org.codehaus.jackson.map包,在下文中一共展示了DeserializationConfig類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: read
import org.codehaus.jackson.map.DeserializationConfig; //導入依賴的package包/類
private void read(DataInput in) throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(
DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS, true);
// define a module
SimpleModule module = new SimpleModule("State Serializer",
new Version(0, 1, 1, "FINAL"));
// add the state deserializer
module.addDeserializer(StatePair.class, new StateDeserializer());
// register the module with the object-mapper
mapper.registerModule(module);
JsonParser parser =
mapper.getJsonFactory().createJsonParser((DataInputStream)in);
StatePool statePool = mapper.readValue(parser, StatePool.class);
this.setStates(statePool.getStates());
parser.close();
}
示例2: configureFeature
import org.codehaus.jackson.map.DeserializationConfig; //導入依賴的package包/類
private void configureFeature(Object feature, boolean enabled) {
if (feature instanceof JsonParser.Feature) {
this.objectMapper.configure((JsonParser.Feature) feature, enabled);
}
else if (feature instanceof JsonGenerator.Feature) {
this.objectMapper.configure((JsonGenerator.Feature) feature, enabled);
}
else if (feature instanceof SerializationConfig.Feature) {
this.objectMapper.configure((SerializationConfig.Feature) feature, enabled);
}
else if (feature instanceof DeserializationConfig.Feature) {
this.objectMapper.configure((DeserializationConfig.Feature) feature, enabled);
}
else {
throw new IllegalArgumentException("Unknown feature class: " + feature.getClass().getName());
}
}
示例3: CustomObjectMapper
import org.codehaus.jackson.map.DeserializationConfig; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
public CustomObjectMapper()
{
super();
this.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
this.configure(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, false);
this.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false);
this.setSerializationInclusion(JsonSerialize.Inclusion.NON_DEFAULT);
this.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);
this.setSerializationInclusion(JsonSerialize.Inclusion.NON_EMPTY);
final AnnotationIntrospector introspector = new JaxbAnnotationIntrospector();
// make deserializer use JAXB annotations (only)
this.setAnnotationIntrospector(introspector);
// TODO leverage NamingStrategy to make reponse attributes more Java-like
//this.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
}
示例4: _findRootDeserializer
import org.codehaus.jackson.map.DeserializationConfig; //導入依賴的package包/類
/**
* Method called to locate deserializer for the passed root-level value.
*/
protected JsonDeserializer<Object> _findRootDeserializer(DeserializationConfig cfg, JavaType valueType)
throws JsonMappingException {
// Sanity check: must have actual type...
if (valueType == null) {
throw new JsonMappingException("No value type configured for ObjectReader");
}
// First: have we already seen it?
JsonDeserializer<Object> deser = _rootDeserializers.get(valueType);
if (deser != null) {
return deser;
}
// es-hadoop: findType with 2 args have been removed since 1.9 so this code compiles on 1.8 (which has the fallback method)
// es-hadoop: on 1.5 only the 2 args method exists, since 1.9 only the one with 3 args hence the if
// Nope: need to ask provider to resolve it
deser = _provider.findTypedValueDeserializer(cfg, valueType);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type " + valueType);
}
_rootDeserializers.put(valueType, deser);
return deser;
}
示例5: JsonObjectMapperParser
import org.codehaus.jackson.map.DeserializationConfig; //導入依賴的package包/類
/**
* Constructor.
*
* @param path
* Path to the JSON data file, possibly compressed.
* @param conf
* @throws IOException
*/
public JsonObjectMapperParser(Path path, Class<? extends T> clazz,
Configuration conf) throws IOException {
mapper = new ObjectMapper();
mapper.configure(
DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS, true);
this.clazz = clazz;
FileSystem fs = path.getFileSystem(conf);
CompressionCodec codec = new CompressionCodecFactory(conf).getCodec(path);
InputStream input;
if (codec == null) {
input = fs.open(path);
decompressor = null;
} else {
FSDataInputStream fsdis = fs.open(path);
decompressor = CodecPool.getDecompressor(codec);
input = codec.createInputStream(fsdis, decompressor);
}
jsonParser = mapper.getJsonFactory().createJsonParser(input);
}
示例6: receiveMessage
import org.codehaus.jackson.map.DeserializationConfig; //導入依賴的package包/類
public void receiveMessage(String message) {
LOGGER.info("Received <" + message + ">");
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
try {
Activity activity = mapper.readValue(message, Activity.class);
ArrayList<User> users = (ArrayList<User>) activity.getSubscribers();
if (users != null) {
for (User user : users) {
websocketHandler.sendMessage(user.getEmail(), message);
}
}
} catch (IOException e) {
LOGGER.info("message is not type of activity");
}
}
示例7: validateUploadInfoFile
import org.codehaus.jackson.map.DeserializationConfig; //導入依賴的package包/類
private BintrayUploadInfo validateUploadInfoFile(FileInfo descriptorJson, BasicStatusHolder status) {
if (!isBintrayJsonInfoFile(descriptorJson.getRepoPath().getName())) {
status.error("The path specified: " + descriptorJson.getRepoPath() + ", does not point to a descriptor. " +
"The file name must contain 'bintray-info' and have a .json extension", SC_NOT_FOUND, log);
return null;
}
BintrayUploadInfo uploadInfo = null;
InputStream jsonContentStream = binaryStore.getBinary(descriptorJson.getSha1());
ObjectMapper mapper = new ObjectMapper(new JsonFactory());
mapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
try {
uploadInfo = mapper.readValue(jsonContentStream, BintrayUploadInfo.class);
} catch (IOException e) {
log.debug("{}", e);
status.error("Can't process the json file: " + e.getMessage(), SC_BAD_REQUEST, log);
} finally {
IOUtils.closeQuietly(jsonContentStream);
}
return uploadInfo;
}
示例8: getDHISOrgUnits
import org.codehaus.jackson.map.DeserializationConfig; //導入依賴的package包/類
@Override
public List<DHISOrganisationUnit> getDHISOrgUnits() {
List<DHISOrganisationUnit> orgUnits = new ArrayList<DHISOrganisationUnit>();
ObjectMapper mapper = new ObjectMapper();
String jsonResponse = new String();
JsonNode node;
jsonResponse = getDataFromDHISEndpoint(DHISCONNECTOR_ORGUNIT_RESOURCE);
try {
mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
node = mapper.readTree(jsonResponse);
orgUnits = Arrays
.asList(mapper.readValue(node.get("organisationUnits").toString(), DHISOrganisationUnit[].class));
}
catch (Exception ex) {
System.out.print(ex.getMessage());
}
return orgUnits;
}
示例9: getByUniqueId
import org.codehaus.jackson.map.DeserializationConfig; //導入依賴的package包/類
@Override
public DHISCategoryCombo getByUniqueId(String s) {
ObjectMapper mapper = new ObjectMapper();
String jsonResponse = Context.getService(DHISConnectorService.class)
.getDataFromDHISEndpoint(CATEGORYCOMBOS_PATH + "/" + s + DHISDataSetsResource.JSON_SUFFIX + COC_FIELDS_PARAM);
DHISCategoryCombo ret = null;
try {
mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
ret = mapper.readValue(jsonResponse, DHISCategoryCombo.class);
}
catch (Exception e) {
log.error(e.getMessage());
}
return ret;
}
示例10: getByUniqueId
import org.codehaus.jackson.map.DeserializationConfig; //導入依賴的package包/類
@Override
public DHISDataSetElement getByUniqueId(String s) {
ObjectMapper mapper = new ObjectMapper();
String jsonResponse = Context.getService(DHISConnectorService.class).getDataFromDHISEndpoint(
DATASETELEMENTS_PATH + "/" + s + CO_FIELDS_PARAM);
mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
DHISDataSetElement ret = null;
try {
if(StringUtils.isNotBlank(jsonResponse))
ret = mapper.readValue(jsonResponse, DHISDataSetElement.class);
} catch (Exception e) {
log.error(e.getMessage());
}
return ret;
}
示例11: getByUniqueId
import org.codehaus.jackson.map.DeserializationConfig; //導入依賴的package包/類
@Override
public DHISDataSet getByUniqueId(String s) {
ObjectMapper mapper = new ObjectMapper();
String jsonResponse = Context.getService(DHISConnectorService.class)
.getDataFromDHISEndpoint(DATASETS_PATH + "/" + s + JSON_SUFFIX + DE_IDENTIFIABLE_PARAM);
DHISDataSet ret = null;
mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
try {
if(StringUtils.isNotBlank(jsonResponse))
ret = mapper.readValue(jsonResponse, DHISDataSet.class);
}
catch (Exception e) {
log.error(e.getMessage());
}
return ret;
}
示例12: doGetAll
import org.codehaus.jackson.map.DeserializationConfig; //導入依賴的package包/類
protected NeedsPaging<DHISDataSet> doGetAll(RequestContext context) {
List<DHISDataSet> dataSets = new ArrayList<DHISDataSet>();
ObjectMapper mapper = new ObjectMapper();
String jsonResponse = new String();
JsonNode node;
jsonResponse = Context.getService(DHISConnectorService.class)
.getDataFromDHISEndpoint(DATASETS_PATH + JSON_SUFFIX + NO_PAGING_PARAM + NO_PAGING_IDENTIFIABLE_PARAM);
try {
mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
if(StringUtils.isNotBlank(jsonResponse)) {
node = mapper.readTree(jsonResponse);
dataSets = Arrays.asList(mapper.readValue(node.get("dataSets").toString(), DHISDataSet[].class));
}
}
catch (Exception ex) {
System.out.print(ex.getMessage());
}
return new NeedsPaging<DHISDataSet>(dataSets, context);
}
示例13: getByUniqueId
import org.codehaus.jackson.map.DeserializationConfig; //導入依賴的package包/類
@Override
public DHISDataElement getByUniqueId(String s) {
ObjectMapper mapper = new ObjectMapper();
String jsonResponse = Context.getService(DHISConnectorService.class).getDataFromDHISEndpoint(
DATAELEMENTS_PATH + "/" + s + DHISDataSetsResource.JSON_SUFFIX + CO_FIELDS_PARAM);
mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
DHISDataElement ret = null;
try {
if (StringUtils.isNotBlank(jsonResponse))
ret = mapper.readValue(jsonResponse, DHISDataElement.class);
} catch (Exception e) {
log.error(e.getMessage());
}
return ret;
}
示例14: parseFile
import org.codehaus.jackson.map.DeserializationConfig; //導入依賴的package包/類
/**
* Parse file received to generate an instance of quality model.
* @param file containing the model in json format
* @return QModel imported
* @throws IOException
* @throws JsonMappingException
* @throws JsonParseException
*/
public static Project parseFile(File file) throws JsonParseException, JsonMappingException, IOException{
Project proj;
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationConfig.Feature.AUTO_DETECT_CREATORS,true);
mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.configure(DeserializationConfig.Feature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true);
mapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
mapper.configure(DeserializationConfig.Feature.USE_GETTERS_AS_SETTERS, false);
proj = mapper.readValue(file, Project.class);
return proj;
}
示例15: parseFile
import org.codehaus.jackson.map.DeserializationConfig; //導入依賴的package包/類
/**
* Parse file received to generate an instance of quality model.
* @param file containing the model in json format
* @return QModel imported
* @throws IOException
* @throws JsonMappingException
* @throws JsonParseException
*/
public static QModel parseFile(File file) throws JsonParseException, JsonMappingException, IOException{
QModel qm;
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationConfig.Feature.AUTO_DETECT_CREATORS,true);
mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.configure(DeserializationConfig.Feature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true);
mapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
mapper.configure(DeserializationConfig.Feature.USE_GETTERS_AS_SETTERS, false);
qm = mapper.readValue(file, QModel.class);
if (qm!=null && (null == qm.getName() || qm.getName().equals("") )) {
qm.setName("Quality Model Imported"+DateTime.now().toDate());
}
return qm;
}