jackson-dataformat-xml

SpringBoot Webflux cannot return application/xml

≡放荡痞女 提交于 2019-12-13 01:09:21
问题 In my reactive REST API I'm trying to return an XML response. However, I always get a JSON , namely 406 NOT_ACCEPTABLE . Any idea why? @RestController @RequestMapping(path = "/xml", produces = APPLICATION_XML_VALUE) public class RestApi { @GetMapping(path = "/get") public Publisher<ResponseEntity> get() { return Mono.just(ResponseEntity.ok().contentType(APPLICATION_XML).body(new Datta("test"))); } @PostMapping(path = "/post", consumes = APPLICATION_XML_VALUE) public Publisher<ResponseEntity

For Date serialization: What is the equivalent annotation of @XmlJavaTypeAdapter from JAXB2 to jackson-dataformat-xml?

て烟熏妆下的殇ゞ 提交于 2019-12-12 19:01:53
问题 I have a Spring Web Application working with the 4.3.6 version. It works with XML and JSON until some point. For Json I use Jackson. For XML I used to work with JAXB2 , but not anymore because it does not support Generic collections A Generic collection is represented such as: public class GenericCollection<T> { private Collection<T> collection; public GenericCollection(){ this.collection = new LinkedHashSet<>(); } public GenericCollection(Collection<T> collection){ this.collection =

How to make Jackson2CodeSupport to support the XML

陌路散爱 提交于 2019-12-11 18:55:31
问题 Typical Spring Boot application. I see that in Jackson2CodeSupport.java class returns false all the type. Because it does not support application/xml , only application/json (the mimeTypes does not contain xml one) protected boolean supportsMimeType(@Nullable MimeType mimeType) { return (mimeType == null || this.mimeTypes.stream().anyMatch(m -> m.isCompatibleWith(mimeType))); } I do have the dependency. com.fasterxml.jackson.dataformat jackson-dataformat-xml 2.9.4 In my code, it starts from

JAXB/Jackson: Sequence of two elements without parent tag

。_饼干妹妹 提交于 2019-12-11 09:47:04
问题 Update : Looking for a Jackson or JAXB solution. After researching a bit about behavior of Jackson, I found that Jackson will always use a wrapper for collections. So probably what I need is not possible to do with Jackson. Hence, added JAXB to title. Original Question I need to create POJO for following XML pattern. <ABWrap> <A></A> <B></B> <A></A> <B></B> ... ... n times </ABWrap> I've tried following POJOs. But these are not generating desired result. class AB { @JacksonXmlProperty

How to skip wrapper object in jackson json deserialization

旧街凉风 提交于 2019-12-11 05:19:36
问题 I am trying to deserialize the following string using the jackson. { "roomName": "u8ec29p0j7q2m9f", "broadcastPresenceRoles": { "broadcastPresenceRole": [ "moderator", "participant", "visitor" ] }, "owners": { "owner": "anewuser@shahanshah" }, "admins": { "admin": "sanjeet@shahanshah" }, "members": null, "outcasts": { "outcast": [ "sawan@shahanshah", "sus@shahanshah" ] }, "ownerGroups": { "ownerGroup": "Friends" } } This the response from the openfire rest apis. I am having problem with the

How to use injection with XmlMapper deserialization

狂风中的少年 提交于 2019-12-11 04:24:23
问题 I am using XmlMapper from com.fasterxml.jackson.dataformat.xml . The class, I am serializing, has an Autowired member that is not serialized. I want to be able to deserialize the XML into an instance and have the autowired member variable populated by Spring . Is there a way to do this? 回答1: ObjectMapper has setInjectableValues method which allow to register some external beans which we want to use during serialisation / deserialisation . For example, DeserializationContext class has

json xml converter having array in json string

让人想犯罪 __ 提交于 2019-12-02 05:34:15
I need to convert a json to xml and later on converting that json back to xml, but i am loosing the json array object while this conversion - I am using org.json lib. Json String - { "readResult": { "errors": [{ "code": 400 }] } } Codebase - using org.json lib String xml = XML.toString(new JSONObject("inputjsonstring")); String json = XML.toJSONObject(xml).toString(); Output xml and json - XML - <readResult><errors><code>400</code></errors></readResult> JSON - { "readResult": { "errors": { "code": 400 } } } Here this json doesn't have any array as it was in original json. Please suggest