當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。