当前位置: 首页>>代码示例>>Java>>正文


Java ObjectMapper.enable方法代码示例

本文整理汇总了Java中com.fasterxml.jackson.databind.ObjectMapper.enable方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectMapper.enable方法的具体用法?Java ObjectMapper.enable怎么用?Java ObjectMapper.enable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.fasterxml.jackson.databind.ObjectMapper的用法示例。


在下文中一共展示了ObjectMapper.enable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getJsonSchema

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public String getJsonSchema() {
	ObjectMapper mapper = new ObjectMapper();
	try {
		mapper.enable(SerializationFeature.INDENT_OUTPUT);
		return mapper.writeValueAsString(jsonSchema);
	} catch (JsonProcessingException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:damianwajser,项目名称:spring-rest-commons-options,代码行数:10,代码来源:BodyRaml.java

示例2: writeTypescriptConfig

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
private void writeTypescriptConfig() throws IOException {
	ObjectMapper mapper = new ObjectMapper();
	mapper.enable(SerializationFeature.INDENT_OUTPUT);
	ObjectNode root = mapper.createObjectNode();
	ObjectNode compilerOptions = root.putObject("compilerOptions");
	compilerOptions.put("baseUrl", "");
	compilerOptions.put("declaration", true);
	compilerOptions.put("emitDecoratorMetadata", true);
	compilerOptions.put("experimentalDecorators", true);
	compilerOptions.put("module", "es6");
	compilerOptions.put("moduleResolution", "node");
	compilerOptions.put("sourceMap", true);
	compilerOptions.put("target", "es5");
	ArrayNode typeArrays = compilerOptions.putArray("typeRoots");
	typeArrays.add("node_modules/@types");
	ArrayNode libs = compilerOptions.putArray("lib");
	libs.add("es6");
	libs.add("dom");

	File outputSourceDir = new File(outputDir, config.getSourceDirectoryName());
	File file = new File(outputSourceDir, "tsconfig.json");
	file.getParentFile().mkdirs();
	mapper.writer().writeValue(file, root);
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:25,代码来源:TSGenerator.java

示例3: configure

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Override
public void configure(Map configs, boolean isKey) {
    String documentBasePackage = (String) configs.get("documentBasePackage");

    SimpleModule module = new SimpleModule();
    Set<Class<?>> annotatedClasses = ClassUtils.getAnnotatedClasses(documentBasePackage, Document.class);
    annotatedClasses.forEach(aClass -> module.addSerializer(aClass, new MetaableJkesJsonSerializer<>()));

    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(module);

    // mapper.enable(SerializationFeature.INDENT_OUTPUT);
    mapper.enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); // Feature is enabled by default, so that date/time are by default serialized as timestamps.
    mapper.disable(SerializationFeature.WRITE_NULL_MAP_VALUES);

    this.mapper = mapper;
}
 
开发者ID:chaokunyang,项目名称:jkes,代码行数:18,代码来源:JkesKafkaJsonSerializer.java

示例4: generate

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Override
public void generate(Object obj, OutputStream os, boolean prettyPrint) {
    ObjectMapper mapper = new ObjectMapper();

    mapper.configure(SerializationFeature.CLOSE_CLOSEABLE, false);
    mapper.configure(SerializationFeature.FLUSH_AFTER_WRITE_VALUE, false);
    mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
    mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);

    if (prettyPrint) {
        mapper.enable(SerializationFeature.INDENT_OUTPUT);
    }

    SimpleModule module = new SimpleModule();
    module.addSerializer(CfnObject.class, new CfnObjectSerializer(resourceSpecificationService));
    module.addSerializer(IntrinsicFunction.class, new IntrinsicFunctionSerializer());
    mapper.registerModule(module);

    try {
        mapper.writeValue(os, obj);

        os.flush();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:cslee00,项目名称:cfn-core,代码行数:27,代码来源:JsonCloudFormationGenerator.java

示例5: DebugEndpoint

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public DebugEndpoint() {
    om = new ObjectMapper();
    om.enable(SerializationFeature.INDENT_OUTPUT);
}
 
开发者ID:redlink-gmbh,项目名称:smarti,代码行数:5,代码来源:DebugEndpoint.java

示例6: loadJson

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
private JsonNode loadJson(InputStream inputStream) throws IOException {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.enable(JsonParser.Feature.ALLOW_COMMENTS);
    return objectMapper.readTree(inputStream);
}
 
开发者ID:zezutom,项目名称:schematic,代码行数:6,代码来源:JsonSchemaParser.java

示例7: jsonBeautify

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
private static String jsonBeautify(String input) {
	ObjectMapper objectMapper = new ObjectMapper();
	objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
    objectMapper.setDefaultPrettyPrinter(PrettyPrinter.instance);		
	JsonNode tree;
	String output;
	try {
		tree = objectMapper.readTree(input);
		output = objectMapper.writeValueAsString(tree);
	} catch (IOException e) {
		return input;
	}
	return output;
}
 
开发者ID:mvetsch,项目名称:JWT4B,代码行数:15,代码来源:ReadableTokenFormat.java

示例8: toJson

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
private String toJson(final Object object) throws JsonProcessingException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.enable(SerializationFeature.INDENT_OUTPUT);
    String jsonRep = "";
    jsonRep = mapper.writeValueAsString(object);
    return jsonRep;
}
 
开发者ID:HewlettPackard,项目名称:loom,代码行数:8,代码来源:SwiftRealAdapterTestLocalOnly.java

示例9: writeDataToFile

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
private void writeDataToFile() throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.enable(SerializationFeature.INDENT_OUTPUT);
    File recordFile = getRecordFile(testName);
    recordFile.createNewFile();
    mapper.writeValue(recordFile, recordedData);
}
 
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:8,代码来源:InterceptorManager.java

示例10: fromJson

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
default ConfigurationType fromJson(InputStream inputStream) throws IOException {
    TypeReference<ConfigurationType> typeReference = new TypeReference<ConfigurationType>() {
    };
    ObjectMapper mapper = new ObjectMapper();
    mapper.enable(JsonParser.Feature.ALLOW_COMMENTS);
    return mapper.readValue(inputStream, typeReference);
}
 
开发者ID:enauz,项目名称:mmm,代码行数:8,代码来源:Jsonizable.java

示例11: createMapper

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public static ObjectMapper createMapper(boolean pretty) {
    ObjectMapper mapper = new ObjectMapper();
    if (pretty) {
        mapper.enable(SerializationFeature.INDENT_OUTPUT);
    }
    return mapper;
}
 
开发者ID:talentchain,项目名称:talchain,代码行数:8,代码来源:Serializers.java

示例12: DrillConfig

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@VisibleForTesting
public DrillConfig(Config config, boolean enableServerConfigs) {
  super(config);
  logger.debug("Setting up DrillConfig object.");
  logger.trace("Given Config object is:\n{}",
               config.root().render(ConfigRenderOptions.defaults()));
  mapper = new ObjectMapper();

  if (enableServerConfigs) {
    SimpleModule deserModule = new SimpleModule("LogicalExpressionDeserializationModule")
      .addDeserializer(LogicalExpression.class, new LogicalExpression.De(this))
      .addDeserializer(SchemaPath.class, new SchemaPath.De());

    mapper.registerModule(deserModule);
    mapper.enable(SerializationFeature.INDENT_OUTPUT);
    mapper.configure(Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
    mapper.configure(JsonGenerator.Feature.QUOTE_FIELD_NAMES, true);
    mapper.configure(Feature.ALLOW_COMMENTS, true);
    mapper.registerSubtypes(LogicalOperatorBase.getSubTypes(this));
    mapper.registerSubtypes(StoragePluginConfigBase.getSubTypes(this));
    mapper.registerSubtypes(FormatPluginConfigBase.getSubTypes(this));
  }

  RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean();
  this.startupArguments = ImmutableList.copyOf(bean.getInputArguments());
  logger.debug("DrillConfig object initialized.");
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:28,代码来源:DrillConfig.java

示例13: toJson

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Test
public void toJson() throws Exception {
  String expected = "{\"accessControlType\":\"READ_ONLY\",\"databasePrefix\":\"name_\",\"federationType\":\"FEDERATED\",\"mappedDatabases\":[],\"metastoreTunnel\":null,\"name\":\"name\",\"remoteMetaStoreUris\":\"uri\",\"status\":\"UNKNOWN\"}";
  ObjectMapper mapper = new ObjectMapper();
  // Sorting to get deterministic test behaviour
  mapper.enable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY);
  String json = mapper.writerFor(FederatedMetaStore.class).writeValueAsString(metaStore);
  assertThat(json, is(expected));
}
 
开发者ID:HotelsDotCom,项目名称:waggle-dance,代码行数:10,代码来源:FederatedMetaStoreTest.java

示例14: getInstance

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public static ProjectServices getInstance() {
     if(instance == null) {
        instance = new ProjectServices();
        mapper = new ObjectMapper();
        mapper.registerModule(new HueSerDeModule());
        
        mapper.enable(SerializationFeature.INDENT_OUTPUT);
        mapper.enable(JsonParser.Feature.ALLOW_COMMENTS);
        mapper.enable(JsonParser.Feature.ALLOW_SINGLE_QUOTES);
        mapper.enable(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES);
     }
     return instance;
}
 
开发者ID:ajoabraham,项目名称:hue,代码行数:14,代码来源:ProjectServices.java

示例15: setup

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Before
public void setup(){
	mapper = new ObjectMapper();
       mapper.registerModule(new HueSerDeModule());
       
       mapper.enable(SerializationFeature.INDENT_OUTPUT);
       mapper.enable(JsonParser.Feature.ALLOW_COMMENTS);
       mapper.enable(JsonParser.Feature.ALLOW_SINGLE_QUOTES);
       mapper.enable(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES);
}
 
开发者ID:ajoabraham,项目名称:hue,代码行数:11,代码来源:PersistOpsTest.java


注:本文中的com.fasterxml.jackson.databind.ObjectMapper.enable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。