本文整理汇总了Java中com.fasterxml.jackson.dataformat.xml.JacksonXmlModule.setDefaultUseWrapper方法的典型用法代码示例。如果您正苦于以下问题:Java JacksonXmlModule.setDefaultUseWrapper方法的具体用法?Java JacksonXmlModule.setDefaultUseWrapper怎么用?Java JacksonXmlModule.setDefaultUseWrapper使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.dataformat.xml.JacksonXmlModule
的用法示例。
在下文中一共展示了JacksonXmlModule.setDefaultUseWrapper方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newInstance
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; //导入方法依赖的package包/类
/**
* Creates properly configured Jackson XML Mapper instances.
* @return XmlMapper instance.
*/
public static XmlMapper newInstance() {
// Create new mapper
final JacksonXmlModule module = new JacksonXmlModule();
module.setDefaultUseWrapper(false);
XmlMapper mapper = new XmlMapper(module);
// Configure it
mapper
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE)
.registerModule(new JodaModule())
.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
return mapper;
}
示例2: POMXmlMapper
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; //导入方法依赖的package包/类
public POMXmlMapper() {
JacksonXmlModule xmlModule = new JacksonXmlModule();
xmlModule.setDefaultUseWrapper(false);
registerModule(xmlModule);
// registerModule(new JaxbAnnotationModule());
registerModule(new HealthTimeModule());
registerModule(new MetricsModule(TimeUnit.SECONDS, TimeUnit.MILLISECONDS, false));
configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, false);
setSerializationInclusion(JsonInclude.Include.NON_NULL);
// setAnnotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()));
addMixInAnnotations(IPOMObject.class, POMObjectJacksonXmlAnnotations.class);
}
示例3: exportStream
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; //导入方法依赖的package包/类
@Override
public void exportStream(OutputStream outputStream, Iterator<T> iterator) throws IOException, ClassNotFoundException, IllegalAccessException {
JacksonXmlModule module = new JacksonXmlModule();
module.setDefaultUseWrapper(false);
XmlMapper xmlMapper = new XmlMapper(module);
XmlFactory factory = new XmlFactory();
ToXmlGenerator generator = factory.createGenerator(outputStream);
generator.setCodec(xmlMapper);
generator.writeRaw("<xml>");
while (iterator.hasNext()) {
generator.writeRaw(xmlMapper.writeValueAsString(iterator.next()));
}
generator.writeRaw("</xml>");
generator.flush();
}
示例4: Response
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; //导入方法依赖的package包/类
public Response(Map<String, String> headers, int httpStatus, String payload) {
// configure the JacksonXml mapper in a cleaner way...
JacksonXmlModule module = new JacksonXmlModule();
// Check out: https://github.com/FasterXML/jackson-dataformat-xml
// setDefaultUseWrapper produces more similar output to
// the Json output. You can change that with annotations in your
// models.
module.setDefaultUseWrapper(false);
this.xmlMapper = new XmlMapper(module);
this.objectMapper = new ObjectMapper();
this.headers = headers;
this.httpStatus = httpStatus;
this.payload = payload;
}
示例5: ResponseHandler
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; //导入方法依赖的package包/类
/**
* Default constructor.
*/
public ResponseHandler() {
// Create new mapper
final JacksonXmlModule module = new JacksonXmlModule();
module.setDefaultUseWrapper(false);
mapper = new XmlMapper(module);
// Configure it
mapper
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE)
.registerModule(new JodaModule())
.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
}
示例6: newInstance
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; //导入方法依赖的package包/类
public static UpgradeProcessorsConfig newInstance(Path configFilePath)
throws JsonParseException, JsonMappingException, IOException {
JacksonXmlModule module = new JacksonXmlModule();
module.setDefaultUseWrapper(false);
XmlMapper xmlMapper = new XmlMapper(module);
return xmlMapper.readValue(configFilePath.toFile(), UpgradeProcessorsConfig.class);
}
示例7: save
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; //导入方法依赖的package包/类
private void save()
{
saveTunerConfigurationModel();
SystemProperties props = SystemProperties.getInstance();
Path settingsFolder = props.getApplicationFolder("settings");
String settingsDefault = props.get("settings.defaultFilename",
"settings.xml");
String settingsCurrent = props.get("settings.currentFilename",
settingsDefault);
Path settingsPath = settingsFolder.resolve(settingsCurrent);
try(OutputStream out = Files.newOutputStream(settingsPath))
{
JacksonXmlModule xmlModule = new JacksonXmlModule();
xmlModule.setDefaultUseWrapper(false);
ObjectMapper objectMapper = new XmlMapper(xmlModule);
objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
objectMapper.writeValue(out, mSettings);
out.flush();
}
catch(IOException ioe)
{
mLog.error("IO error while writing the settings to a file [" + settingsPath + "]", ioe);
}
catch(Exception e)
{
mLog.error("Error while saving settings file [" + settingsPath + "]", e);
}
}
示例8: load
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; //导入方法依赖的package包/类
/**
* Erases current settings and loads settings from the settingsPath filename,
* if it exists.
*/
public void load(Path settingsPath)
{
mLoadingSettings = true;
if(Files.exists(settingsPath))
{
mLog.info("SettingsManager - loading settings file [" + settingsPath.toString() + "]");
JacksonXmlModule xmlModule = new JacksonXmlModule();
xmlModule.setDefaultUseWrapper(false);
ObjectMapper objectMapper = new XmlMapper(xmlModule);
try(InputStream in = Files.newInputStream(settingsPath))
{
mSettings = objectMapper.readValue(in, Settings.class);
}
catch(IOException ioe)
{
mLog.error("IO error while reading settings file", ioe);
}
}
else
{
mLog.info("SettingsManager - settings does not exist [" +
settingsPath.toString() + "]");
}
if(mSettings == null)
{
mSettings = new Settings();
}
loadTunerConfigurationModel();
mLoadingSettings = false;
}
示例9: Ds3SpecParserImpl
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; //导入方法依赖的package包/类
public Ds3SpecParserImpl() {
module = new JacksonXmlModule();
module.setDefaultUseWrapper(false);
mapper = new XmlMapper(module);
mapper.registerModule(new GuavaModule());
final SimpleFilterProvider filterProvider = new SimpleFilterProvider().setFailOnUnknownId(false);
mapper.setFilters(filterProvider);
}
示例10: getObjectMapper
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; //导入方法依赖的package包/类
@Override
protected ObjectMapper getObjectMapper() {
// Check out: https://github.com/FasterXML/jackson-dataformat-xml
JacksonXmlModule module = new JacksonXmlModule();
// setDefaultUseWrapper produces more similar output to
// the Json output. You can change that with annotations in your
// models.
module.setDefaultUseWrapper(false);
return new XmlMapper(module);
}
示例11: registerModules
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; //导入方法依赖的package包/类
@Override
protected void registerModules(ObjectMapper mapper) {
JacksonXmlModule module = new JacksonXmlModule();
module.setDefaultUseWrapper(false);
mapper.registerModule(module);
}
示例12: testGetAndPostArticleViaXml
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; //导入方法依赖的package包/类
@Test
public void testGetAndPostArticleViaXml() throws Exception {
// /////////////////////////////////////////////////////////////////////
// Test initial data:
// /////////////////////////////////////////////////////////////////////
String response = ninjaTestBrowser.makeXmlRequest(getServerAddress()
+ "api/[email protected]/articles.xml");
System.out.println("response xml: " + response);
JacksonXmlModule module = new JacksonXmlModule();
// and then configure, for example:
module.setDefaultUseWrapper(false);
XmlMapper xmlMapper = new XmlMapper(module);
ArticlesDto articlesDto = xmlMapper.readValue(response, ArticlesDto.class);
assertEquals(3, articlesDto.articles.size());
// /////////////////////////////////////////////////////////////////////
// Post new article:
// /////////////////////////////////////////////////////////////////////
ArticleDto articleDto = new ArticleDto();
articleDto.content = "contentcontent";
articleDto.title = "new title new title";
response = ninjaTestBrowser.postXml(getServerAddress()
+ "api/[email protected]/article.xml", articleDto);
assertTrue(response.contains("Error. Forbidden."));
doLogin();
response = ninjaTestBrowser.postXml(getServerAddress()
+ "api/[email protected]/article.xml", articleDto);
assertFalse(response.contains("Error. Forbidden."));
// /////////////////////////////////////////////////////////////////////
// Fetch articles again => assert we got a new one ...
// /////////////////////////////////////////////////////////////////////
response = ninjaTestBrowser.makeXmlRequest(getServerAddress()
+ "api/[email protected]/articles.xml");
articlesDto = xmlMapper.readValue(response, ArticlesDto.class);
// one new result:
assertEquals(4, articlesDto.articles.size());
}