Java 类org.codehaus.jackson.map.DeserializationConfig 实例源码

项目:hadoop-2.6.0-cdh5.4.3    文件:StatePool.java   
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();
}
项目:hadoop-plus    文件:StatePool.java   
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();
}
项目:lams    文件:JacksonObjectMapperFactoryBean.java   
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());
    }
}
项目:hadoop    文件:StatePool.java   
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();
}
项目:aliyun-oss-hadoop-fs    文件:StatePool.java   
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();
}
项目:big-c    文件:StatePool.java   
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();
}
项目:SAP-cloud-dqm-sample-java    文件:CustomObjectMapper.java   
/**
 * {@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);
}
项目:es-hadoop-v2.2.0    文件:BackportedObjectReader.java   
/**
 * 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;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:JsonObjectMapperParser.java   
/**
 * 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);
}
项目:hadoop-EAR    文件:JsonObjectMapperParser.java   
/**
 * 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);
}
项目:onboard    文件:RedisMessageReceiver.java   
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");
    }
}
项目:artifactory    文件:BintrayServiceImpl.java   
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;
}
项目:openmrs-module-dhisconnector    文件:DHISConnectorServiceImpl.java   
@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;
}
项目:openmrs-module-dhisconnector    文件:DHISCategoryCombosResource.java   
@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;
}
项目:openmrs-module-dhisconnector    文件:DHISDataSetElementResource.java   
@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;
}
项目:openmrs-module-dhisconnector    文件:DHISDataSetsResource.java   
@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;

}
项目:openmrs-module-dhisconnector    文件:DHISDataSetsResource.java   
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);
}
项目:openmrs-module-dhisconnector    文件:DHISDataElementsResource.java   
@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;
}
项目:hops    文件:StatePool.java   
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();
}
项目:u-qasar.platform    文件:QProjectJsonParser.java   
/**
 * 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;
}
项目:u-qasar.platform    文件:QModelJsonParser.java   
/**
 * 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;
}
项目:jrs-rest-java-client    文件:SessionStorage.java   
protected WebTarget configClient() {
    JacksonJsonProvider customRepresentationTypeProvider = new CustomRepresentationTypeProvider()
            .configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    rootTarget = client.target(configuration.getJasperReportsServerUrl());
    rootTarget
            .register(customRepresentationTypeProvider)
            .register(JacksonFeature.class)
            .register(MultiPartWriter.class);
    if (sessionId != null) {
        rootTarget.register(new SessionOutputFilter(sessionId));
    }
    if (configuration.getLogHttp()) {
        rootTarget.register(initLoggingFilter());
    }
    return rootTarget;
}
项目:12306-android-Decompile    文件:BeanDeserializerFactory.java   
protected void addReferenceProperties(DeserializationConfig paramDeserializationConfig, BasicBeanDescription paramBasicBeanDescription, BeanDeserializerBuilder paramBeanDeserializerBuilder)
  throws JsonMappingException
{
  Map localMap = paramBasicBeanDescription.findBackReferenceProperties();
  if (localMap != null)
  {
    Iterator localIterator = localMap.entrySet().iterator();
    while (localIterator.hasNext())
    {
      Map.Entry localEntry = (Map.Entry)localIterator.next();
      String str = (String)localEntry.getKey();
      AnnotatedMember localAnnotatedMember = (AnnotatedMember)localEntry.getValue();
      if ((localAnnotatedMember instanceof AnnotatedMethod))
      {
        paramBeanDeserializerBuilder.addBackReferenceProperty(str, constructSettableProperty(paramDeserializationConfig, paramBasicBeanDescription, localAnnotatedMember.getName(), (AnnotatedMethod)localAnnotatedMember));
        continue;
      }
      paramBeanDeserializerBuilder.addBackReferenceProperty(str, constructSettableProperty(paramDeserializationConfig, paramBasicBeanDescription, localAnnotatedMember.getName(), (AnnotatedField)localAnnotatedMember));
    }
  }
}
项目:jira-rest-client    文件:ProjectService.java   
public List<Project> getProjectList() throws IOException {
    if (client == null)
        throw new IllegalStateException("HTTP Client not Initailized");

    client.setResourceName(Constants.JIRA_RESOURCE_PROJECT);
    ClientResponse response = client.get();

    String content = response.getEntity(String.class);  

    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, true);

    TypeReference<List<Project>> ref = new TypeReference<List<Project>>(){};
    List<Project> prj = mapper.readValue(content, ref);

    return prj;
}
项目:jira-rest-client    文件:ProjectService.java   
public Project getProjectDetail(String idOrKey) throws IOException {
    if (client == null)
        throw new IllegalStateException("HTTP Client not Initailized");

    client.setResourceName(Constants.JIRA_RESOURCE_PROJECT + "/" + idOrKey);
    ClientResponse response = client.get();

    String content = response.getEntity(String.class);  

    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, true);

    TypeReference<Project> ref = new TypeReference<Project>(){};
    Project prj = mapper.readValue(content, ref);

    return prj;
}
项目:12306-android-Decompile    文件:BeanDeserializerFactory.java   
protected CreatorContainer findDeserializerCreators(DeserializationConfig paramDeserializationConfig, BasicBeanDescription paramBasicBeanDescription)
  throws JsonMappingException
{
  boolean bool = paramDeserializationConfig.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS);
  CreatorContainer localCreatorContainer = new CreatorContainer(paramBasicBeanDescription, bool);
  AnnotationIntrospector localAnnotationIntrospector = paramDeserializationConfig.getAnnotationIntrospector();
  if (paramBasicBeanDescription.getType().isConcrete())
  {
    Constructor localConstructor = paramBasicBeanDescription.findDefaultConstructor();
    if (localConstructor != null)
    {
      if (bool)
        ClassUtil.checkAndFixAccess(localConstructor);
      localCreatorContainer.setDefaultConstructor(localConstructor);
    }
  }
  VisibilityChecker localVisibilityChecker1 = paramDeserializationConfig.getDefaultVisibilityChecker();
  if (!paramDeserializationConfig.isEnabled(DeserializationConfig.Feature.AUTO_DETECT_CREATORS))
    localVisibilityChecker1 = localVisibilityChecker1.withCreatorVisibility(JsonAutoDetect.Visibility.NONE);
  VisibilityChecker localVisibilityChecker2 = paramDeserializationConfig.getAnnotationIntrospector().findAutoDetectVisibility(paramBasicBeanDescription.getClassInfo(), localVisibilityChecker1);
  _addDeserializerConstructors(paramDeserializationConfig, paramBasicBeanDescription, localVisibilityChecker2, localAnnotationIntrospector, localCreatorContainer);
  _addDeserializerFactoryMethods(paramDeserializationConfig, paramBasicBeanDescription, localVisibilityChecker2, localAnnotationIntrospector, localCreatorContainer);
  return localCreatorContainer;
}
项目:gae-jersey-guice-jsf    文件:Jackson1.java   
public static ObjectMapper createFieldsMapper()
    {
        ObjectMapper mapper = new ObjectMapper();

        // limit to fields only
        mapper.enable(SerializationConfig.Feature.AUTO_DETECT_FIELDS);
        mapper.enable(DeserializationConfig.Feature.AUTO_DETECT_FIELDS);
        mapper.disable(SerializationConfig.Feature.AUTO_DETECT_GETTERS);
        mapper.disable(SerializationConfig.Feature.AUTO_DETECT_IS_GETTERS);
        mapper.disable(DeserializationConfig.Feature.AUTO_DETECT_SETTERS);
        mapper.disable(DeserializationConfig.Feature.AUTO_DETECT_CREATORS);

        // general configuration
        mapper.setSerializationInclusion(Inclusion.NON_NULL);
        mapper.enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
//      json.disable(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES);

        return mapper;
    }
项目:12306-android-Decompile    文件:EnumDeserializer.java   
public Enum<?> deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  JsonToken localJsonToken = paramJsonParser.getCurrentToken();
  if (localJsonToken == JsonToken.VALUE_STRING)
  {
    String str = paramJsonParser.getText();
    Enum localEnum2 = this._resolver.findEnum(str);
    if (localEnum2 == null)
      throw paramDeserializationContext.weirdStringException(this._resolver.getEnumClass(), "value not one of declared Enum instance names");
    return localEnum2;
  }
  if (localJsonToken == JsonToken.VALUE_NUMBER_INT)
  {
    if (paramDeserializationContext.isEnabled(DeserializationConfig.Feature.FAIL_ON_NUMBERS_FOR_ENUMS))
      throw paramDeserializationContext.mappingException("Not allowed to deserialize Enum value out of JSON number (disable DeserializationConfig.Feature.FAIL_ON_NUMBERS_FOR_ENUMS to allow)");
    int i = paramJsonParser.getIntValue();
    Enum localEnum1 = this._resolver.getEnum(i);
    if (localEnum1 == null)
      throw paramDeserializationContext.weirdNumberException(this._resolver.getEnumClass(), "index value outside legal index range [0.." + this._resolver.lastValidIndex() + "]");
    return localEnum1;
  }
  throw paramDeserializationContext.mappingException(this._resolver.getEnumClass());
}
项目:12306-android-Decompile    文件:BeanDeserializerFactory.java   
public KeyDeserializer createKeyDeserializer(DeserializationConfig paramDeserializationConfig, JavaType paramJavaType, BeanProperty paramBeanProperty)
  throws JsonMappingException
{
  if (this._factoryConfig.hasKeyDeserializers())
  {
    BasicBeanDescription localBasicBeanDescription = (BasicBeanDescription)paramDeserializationConfig.introspectClassAnnotations(paramJavaType.getRawClass());
    Iterator localIterator = this._factoryConfig.keyDeserializers().iterator();
    while (localIterator.hasNext())
    {
      KeyDeserializer localKeyDeserializer = ((KeyDeserializers)localIterator.next()).findKeyDeserializer(paramJavaType, paramDeserializationConfig, localBasicBeanDescription, paramBeanProperty);
      if (localKeyDeserializer != null)
        return localKeyDeserializer;
    }
  }
  return null;
}
项目:helix    文件:PropertyJsonSerializer.java   
@Override
public T deserialize(byte[] bytes) throws PropertyStoreException {
  ObjectMapper mapper = new ObjectMapper();
  ByteArrayInputStream bais = new ByteArrayInputStream(bytes);

  DeserializationConfig deserializationConfig = mapper.getDeserializationConfig();
  deserializationConfig.set(DeserializationConfig.Feature.AUTO_DETECT_FIELDS, true);
  deserializationConfig.set(DeserializationConfig.Feature.AUTO_DETECT_SETTERS, true);
  deserializationConfig.set(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, true);
  try {
    T value = mapper.readValue(bais, _clazz);
    return value;
  } catch (Exception e) {
    LOG.error("Error during deserialization of bytes: " + new String(bytes), e);
  }

  return null;
}
项目:socialeyeser    文件:AbstractFeatureTestCase.java   
public AbstractFeatureTestCase() throws IOException, URISyntaxException {

    final FileInputStream stream = new FileInputStream(new File(this.getClass()
            .getResource(SAMPLE_TWEET_FILENAME).toURI()));
    try {
        final FileChannel fc = stream.getChannel();
        final MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
        String json = Charset.defaultCharset().decode(bb).toString();

        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        objectMapper
                .setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
        objectMapper.setDateFormat(new SimpleDateFormat("EEE MMM dd HH:mm:ss ZZZZZ yyyy"));

        sampleTweet = objectMapper.readValue(json, Tweet.class);
    } finally {
        stream.close();
    }

}
项目:hardfs    文件:StatePool.java   
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();
}
项目:RDFS    文件:JsonObjectMapperParser.java   
/**
 * 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);
}
项目:12306-android-Decompile    文件:BasicDeserializerFactory.java   
public JsonDeserializer<?> createCollectionLikeDeserializer(DeserializationConfig paramDeserializationConfig, DeserializerProvider paramDeserializerProvider, CollectionLikeType paramCollectionLikeType, BeanProperty paramBeanProperty)
  throws JsonMappingException
{
  CollectionLikeType localCollectionLikeType1 = (CollectionLikeType)mapAbstractType(paramDeserializationConfig, paramCollectionLikeType);
  BasicBeanDescription localBasicBeanDescription = (BasicBeanDescription)paramDeserializationConfig.introspectClassAnnotations(localCollectionLikeType1.getRawClass());
  JsonDeserializer localJsonDeserializer1 = findDeserializerFromAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), paramBeanProperty);
  if (localJsonDeserializer1 != null)
    return localJsonDeserializer1;
  CollectionLikeType localCollectionLikeType2 = (CollectionLikeType)modifyTypeByAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), localCollectionLikeType1, null);
  JavaType localJavaType = localCollectionLikeType2.getContentType();
  JsonDeserializer localJsonDeserializer2 = (JsonDeserializer)localJavaType.getValueHandler();
  TypeDeserializer localTypeDeserializer = (TypeDeserializer)localJavaType.getTypeHandler();
  if (localTypeDeserializer == null)
    localTypeDeserializer = findTypeDeserializer(paramDeserializationConfig, localJavaType, paramBeanProperty);
  return _findCustomCollectionLikeDeserializer(localCollectionLikeType2, paramDeserializationConfig, paramDeserializerProvider, localBasicBeanDescription, paramBeanProperty, localTypeDeserializer, localJsonDeserializer2);
}
项目:12306-android-Decompile    文件:BasicDeserializerFactory.java   
public JsonDeserializer<?> createMapLikeDeserializer(DeserializationConfig paramDeserializationConfig, DeserializerProvider paramDeserializerProvider, MapLikeType paramMapLikeType, BeanProperty paramBeanProperty)
  throws JsonMappingException
{
  MapLikeType localMapLikeType1 = (MapLikeType)mapAbstractType(paramDeserializationConfig, paramMapLikeType);
  BasicBeanDescription localBasicBeanDescription = (BasicBeanDescription)paramDeserializationConfig.introspectForCreation(localMapLikeType1);
  JsonDeserializer localJsonDeserializer1 = findDeserializerFromAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), paramBeanProperty);
  if (localJsonDeserializer1 != null)
    return localJsonDeserializer1;
  MapLikeType localMapLikeType2 = (MapLikeType)modifyTypeByAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), localMapLikeType1, null);
  JavaType localJavaType1 = localMapLikeType2.getKeyType();
  JavaType localJavaType2 = localMapLikeType2.getContentType();
  JsonDeserializer localJsonDeserializer2 = (JsonDeserializer)localJavaType2.getValueHandler();
  KeyDeserializer localKeyDeserializer = (KeyDeserializer)localJavaType1.getValueHandler();
  if (localKeyDeserializer == null)
    localKeyDeserializer = paramDeserializerProvider.findKeyDeserializer(paramDeserializationConfig, localJavaType1, paramBeanProperty);
  TypeDeserializer localTypeDeserializer = (TypeDeserializer)localJavaType2.getTypeHandler();
  if (localTypeDeserializer == null)
    localTypeDeserializer = findTypeDeserializer(paramDeserializationConfig, localJavaType2, paramBeanProperty);
  return _findCustomMapLikeDeserializer(localMapLikeType2, paramDeserializationConfig, paramDeserializerProvider, localBasicBeanDescription, paramBeanProperty, localKeyDeserializer, localTypeDeserializer, localJsonDeserializer2);
}
项目:12306-android-Decompile    文件:BasicDeserializerFactory.java   
protected JsonDeserializer<Object> findStdBeanDeserializer(DeserializationConfig paramDeserializationConfig, DeserializerProvider paramDeserializerProvider, JavaType paramJavaType, BeanProperty paramBeanProperty)
  throws JsonMappingException
{
  JsonDeserializer localJsonDeserializer1 = (JsonDeserializer)_simpleDeserializers.get(paramJavaType);
  if (localJsonDeserializer1 != null)
    return localJsonDeserializer1;
  if (AtomicReference.class.isAssignableFrom(paramJavaType.getRawClass()))
  {
    JavaType[] arrayOfJavaType = paramDeserializationConfig.getTypeFactory().findTypeParameters(paramJavaType, AtomicReference.class);
    if ((arrayOfJavaType == null) || (arrayOfJavaType.length < 1));
    for (JavaType localJavaType = TypeFactory.unknownType(); ; localJavaType = arrayOfJavaType[0])
      return new StdDeserializer.AtomicReferenceDeserializer(localJavaType, paramBeanProperty);
  }
  JsonDeserializer localJsonDeserializer2 = this.optionalHandlers.findDeserializer(paramJavaType, paramDeserializationConfig, paramDeserializerProvider);
  if (localJsonDeserializer2 != null)
    return localJsonDeserializer2;
  return null;
}
项目:socialeyeser    文件:StreamReplayer.java   
public StreamReplayer(double speedFactor, String jsonZipPath) {

    this.speedFactor = speedFactor;

    this.mapper = new ObjectMapper();
    this.mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    this.mapper
            .setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
    this.mapper.setDateFormat(new SimpleDateFormat("EEE MMM dd HH:mm:ss ZZZZZ yyyy"));

    try {
        initStream(jsonZipPath);
    } catch (IOException e) {
        LOGGER.error("Could not init stream: " + e.getMessage());
    }

}
项目:hadoop-on-lustre2    文件:StatePool.java   
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();
}
项目:socialeyeser    文件:TrendsMiner.java   
public TrendsMiner(String consumerKey, String consumerSecret, String userKey, String userSecret)
        throws FileNotFoundException {

    stats = new PrintStream(new File("/Data/alerts.txt"));

    this.mapper = new ObjectMapper();
    this.mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    this.mapper
            .setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
    this.mapper.setDateFormat(new SimpleDateFormat("EEE MMM dd HH:mm:ss ZZZZZ yyyy"));

    this.applicationConsumerKey = consumerKey;
    this.applicationConsumerSecret = consumerSecret;
    this.userKey = userKey;
    this.userSecret = userSecret;

    registerShutdownHook();

    initDetector();

}
项目:12306-android-Decompile    文件:StdDeserializerProvider.java   
public JsonDeserializer<Object> findValueDeserializer(DeserializationConfig paramDeserializationConfig, JavaType paramJavaType, BeanProperty paramBeanProperty)
  throws JsonMappingException
{
  JsonDeserializer localJsonDeserializer1 = _findCachedDeserializer(paramJavaType);
  if (localJsonDeserializer1 != null)
  {
    if ((localJsonDeserializer1 instanceof ContextualDeserializer))
      localJsonDeserializer1 = ((ContextualDeserializer)localJsonDeserializer1).createContextual(paramDeserializationConfig, paramBeanProperty);
    return localJsonDeserializer1;
  }
  JsonDeserializer localJsonDeserializer2 = _createAndCacheValueDeserializer(paramDeserializationConfig, paramJavaType, paramBeanProperty);
  if (localJsonDeserializer2 == null)
    localJsonDeserializer2 = _handleUnknownValueDeserializer(paramJavaType);
  if ((localJsonDeserializer2 instanceof ContextualDeserializer))
    localJsonDeserializer2 = ((ContextualDeserializer)localJsonDeserializer2).createContextual(paramDeserializationConfig, paramBeanProperty);
  return localJsonDeserializer2;
}