Re: [jackson-user] How to register a custom deserializer for an entire type hierarchy

2017-12-21 Thread Tatu Saloranta
Good! -+ Tatu +- On Thu, Dec 21, 2017 at 1:39 AM, Bojan Tomic wrote: > Thanks for the advice! I did as you said and managed to achieve what I was > after. > > -- > You received this message because you are subscribed to the Google Groups > "jackson-user" group. > To

Re: [jackson-user] Jackson - InvalidFormatException deserializing ENUM

2018-01-03 Thread Tatu Saloranta
get this in any of > your newer versions. As of now, we are doing a workaround with the Map > implementation to get this fixed. > > Regards, > Remya > > On Friday, 15 December 2017 10:26:05 UTC-6, Remya wrote: >> >> Thank you! >> >> On Thursday, 14 December

Re: [jackson-user] Re: Deprecating, end-of-life'ing FasterXML wiki

2018-08-05 Thread Tatu Saloranta
future and extensive use of the many, perhaps > less obvious features. Np, I did not take it as anything than constructive feedback, and something echoed by many other developers. -+ Tatu +- > > > On Wednesday, November 22, 2017 at 12:06:36 PM UTC-5, Tatu Saloranta wrote: >> >> Due

Re: [jackson-user] Jackson deserialization with polymorphism nested into polymorphism | aka more than one deserializer

2018-08-05 Thread Tatu Saloranta
he node but still with respect > to the object schema. So it will continue deserializing until it finds > AbstractDTO declaration and will use its deserializer to follow up from that > node down its tree.. > > Sorry if I sound a bit confused, but this makes only sense to me

Re: [jackson-user] Windows CentOS differences

2018-08-08 Thread Tatu Saloranta
On Wed, Aug 8, 2018 at 6:52 AM wrote: > > Hello, we have a web app that sits in Tomcat and uses RestEasy > 3.0.16.Final and Jackson 2.5.2. It's built once, using maven, and then > deployed pretty much the same to a Windows 7 and a CentOS 7.2 machines. > > Just in the last week, we've started to

Re: [jackson-user] Can Jackson work with dynamic proxies?

2018-08-15 Thread Tatu Saloranta
On Tue, Aug 14, 2018 at 1:30 PM, Lyubomyr Shaydariv wrote: > Hello, > > I've faced with an issue where I need to work with dynamic proxies since I > find them a very convenient way allowing to reduce the amount of code > dramatically. Please consider the following code: > > interface IUserDto { >

Re: [jackson-user] Can Jackson work with dynamic proxies?

2018-08-15 Thread Tatu Saloranta
would be expected. This is possible using `ValueInstantiator` handler, although bit more work. But plain `JsonDeserializer` delegates all work from databind. I hope this makes sense. -+ Tatu +- > > > On Wednesday, August 15, 2018 at 1:58:14 PM UTC+3, Tatu Saloranta wrote: >> >> On

Re: [jackson-user] Can Jackson work with dynamic proxies?

2018-08-15 Thread Tatu Saloranta
st got side-tracked by the reference to Proxy as I know there are explicit checks wrt Proxy instance types. :) -+ Tatu +- > > > > On Wednesday, August 15, 2018 at 4:45:20 PM UTC+3, Tatu Saloranta wrote: >> >> On Wed, Aug 15, 2018 at 5:05 AM, Lyubomyr Shaydariv >>

Re: [jackson-user] NULL inclusion bug(?) even with Include.NON_NULL

2018-08-05 Thread Tatu Saloranta
On Wed, Jul 18, 2018 at 4:32 AM, Bogdan Vaneev wrote: > I am using jackson-databind 2.9.6: > > compile("com.fasterxml.jackson.core:jackson-databind:2.9.6") > > > And it looks like I found a bug. When object mapper is told to not include > nulls, it still includes if you read JSON to tree, then

Re: [jackson-user] Change access mode in runtime

2018-08-05 Thread Tatu Saloranta
On Wed, Jul 18, 2018 at 8:10 AM, Idan Shay wrote: > Hi, > > I have class that I want to convert to JSON. > > Some of the fields I dont want to be convert to JSON and I am able to do > this by add access mode WRITE_ONLY. > > The problem that I have is with one field that in some case need to be >

Re: [jackson-user] Jackson deserialization with polymorphism nested into polymorphism | aka more than one deserializer

2018-08-05 Thread Tatu Saloranta
On Fri, Jul 20, 2018 at 5:06 AM, Michal Aron wrote: > Hey, > > May somebody please have a look at the following problem? > > It is about nested polymorphism into another object and it fails on > nullPointerException when it meets attribute using abstract class > declaration. > > In other words it

Re: [jackson-user] Re: Wrong JsonStreamContext hierarchy when using JsonNode.traverse TreeTraversingParser

2018-08-31 Thread Tatu Saloranta
Quick answer: sounds like a Jackson bug. Longer answer: maintaining accurate read context hierarchy gets complicated since it needs to "stitch" together contexts from original context (physical parser, originally), and then context for TreeTraversingParser (for JsonNode) or its equivalent for

Re: [jackson-user] Map.Entry implementations deserialization issue

2018-09-05 Thread Tatu Saloranta
On Wed, Sep 5, 2018 at 7:21 AM Alexey Tatarikov wrote: > > Here is sample pojo: > > @Getter > @Setter > @Builder > @NoArgsConstructor > @AllArgsConstructor > public class Pair extends BaseObject implements Map.Entry { > > private T key; > private V value; > > @Override > public V

Re: [jackson-user] Multiple properties with the same name

2018-09-05 Thread Tatu Saloranta
On Wed, Sep 5, 2018 at 1:18 AM wrote: > > I need to serialize/deserialze some xml data like this: > > > 1 > 2 > ... > a > b > c > ... > 3 > 4 > 5 > ... > > > > Where MyPropB has to have at least 1 element! So even for deserialization > it's clear

Re: [jackson-user] StdDeserializer<> and Array Datasets

2018-09-06 Thread Tatu Saloranta
On Wed, Sep 5, 2018 at 9:28 PM Brexton Popejoy wrote: > > I am writing a custom `StdDeserializer` that will take a json with > the root node being an array and import it as an array of RuleSet objects. I > wrote most of the code for a single case (for importing just the first > ruleset from

[jackson-user] Any projects actively using, updating to newer versions of, Jackson 2.7.x? Want to see 2.7.10 release?

2018-09-06 Thread Tatu Saloranta
As many of you know, there have been a few security fixes (for CVEs reported for "default typing" style of polymorphic deserialization). If not familiar with this, please read: https://medium.com/@cowtowncoder/on-jackson-cves-dont-panic-here-is-what-you-need-to-know-54cd0d6e8062 Now: maintaining

Re: [jackson-user] @JsonUnwrapped not working as expected with @JsonProperty

2018-09-10 Thread Tatu Saloranta
On Mon, Sep 10, 2018 at 8:13 AM Slawek Mazur wrote: > > Here's the scenario: > > public class UnwrappedWithPropertyName { > > public static void main(String[] args) throws JsonProcessingException { > > final Address address = new Address(new Postcode("45678")); > > final

Re: [jackson-user] Adding @JsonTypeInfo to interface causes JsonGenerationException

2018-09-10 Thread Tatu Saloranta
On Mon, Sep 10, 2018 at 2:23 PM Dallas Phillips wrote: > > The below example code describes my situation. I need to add the type > information to the serialization of a class. I have other classes that extend > this interface but that should not matter. > > I included a zip of the example code

Re: [jackson-user] serialize fake list

2018-09-07 Thread Tatu Saloranta
On Fri, Sep 7, 2018 at 12:43 PM wrote: > > I defined a class like this: > > public class Record1 extends AbstractList { > int field1; > int field2; > > public int size() { > return 1; > } > public Record1 get(int index){ > if(index == 0){ >return

Re: [jackson-user] Which repo has the sources for jackson-base?

2018-01-16 Thread Tatu Saloranta
Jackson-base is sub-module of `jackson-bom`. So bit obscure unfortunately. Hope this helps, -+ Tatu +- On Tue, Jan 16, 2018 at 8:09 AM, Bojan Tomic wrote: > As discussed in my previous topic on TYPE_USE annotations, I'd like to > experiment a bit to see what it takes to add

Re: [jackson-user] How to distinguish missing fields from null when using property-based JsonCreator?

2018-03-06 Thread Tatu Saloranta
To me keeping additional status on setters on databinding level just does not make much sense, -+ Tatu +- > > On Tuesday, 6 March 2018 03:16:42 UTC, Tatu Saloranta wrote: >> >> On Mon, Mar 5, 2018 at 6:14 PM, <m...@vslice.co.uk> wrote: >> > For bean setters we have &g

Re: [jackson-user] How to distinguish missing fields from null when using property-based JsonCreator?

2018-03-09 Thread Tatu Saloranta
On Wed, Mar 7, 2018 at 7:42 AM, <m...@vslice.co.uk> wrote: > > > On Wednesday, 7 March 2018 04:28:09 UTC, Tatu Saloranta wrote: >> >> On Tue, Mar 6, 2018 at 7:08 PM, <m...@vslice.co.uk> wrote: >> > Thanks, Tatu. Is there any existing discussion arou

Re: [jackson-user] How to get the overridden deserializable type (via BeanDescription)?

2018-03-09 Thread Tatu Saloranta
On Fri, Mar 9, 2018 at 1:27 PM, Bojan Tomic wrote: > I'm building a framework type of thing and ultimately just needed a boolean > saying "Jackson can handle it" or not. > But I get that it's not really the intended usage. Ah. The bigger problem really is that even if you

Re: [jackson-user] How to get the overridden deserializable type (via BeanDescription)?

2018-03-09 Thread Tatu Saloranta
On Fri, Mar 9, 2018 at 2:30 AM, Bojan Tomic <veg...@gmail.com> wrote: > > On Friday, March 9, 2018 at 5:35:49 AM UTC+1, Tatu Saloranta wrote: >> >> >> Logical type of the property is not modified at introspection; type >> refinement only occurs whe

Re: [jackson-user] Is there a replacement for JsonParser#getCodec in Jackson 3

2018-03-11 Thread Tatu Saloranta
On Sat, Mar 10, 2018 at 4:38 PM, Bojan Tomic wrote: > I was going through some critical sections of my code to look for potential > problems for the eventual upgrade to Jackson 3. > One thing that popped out was the usage of JsonParser#getCodec which no > longer exists. > > Is

Re: [jackson-user] How to get the overridden deserializable type (via BeanDescription)?

2018-03-08 Thread Tatu Saloranta
On Thu, Mar 8, 2018 at 5:58 PM, Bojan Tomic wrote: > Given the following class: > > public static class Container { > > private AbstactType item; > > @JsonDeserialize(as = ConcreteType.class) > public AbstactType getItem() { > return item; > } > } > > > I'm now trying to

Re: [jackson-user] Getting lexical information in the tree model?

2018-03-14 Thread Tatu Saloranta
ternate implementation could be done either via `JsonNodeFactory` or, perhaps, deserializer. -+ Tatu +- > > Thanks, > > Rob > > On Monday, 14 November 2016 06:32:39 UTC, Tatu Saloranta wrote: >> >> No, for two reasons: >> >> 1. JsonNode is singly li

Re: [jackson-user] @JsonIgnore doesn't ignore @JsonManagedReference within mixin

2018-04-04 Thread Tatu Saloranta
Does it work if you add `@JsonIgnore` directly on type? I suspect this could be because you are adding mix-in to getter, but `@JsonManagedReference` is added to field. So another thing to checkout would be to try to move one `@ JsonManagedReference` to getter and see if that makes difference. -+

Re: [jackson-user] Backports of CVE-2017-7525

2018-04-04 Thread Tatu Saloranta
This sounds like useful for many users. Thank you for sharing! Some thoughts On 1.x; there is: https://github.com/FasterXML/jackson-1 from which it would be nice to still release 1.9.14. But as things are, there is no Maven release process into Nexus that works (1.x uses/used Ant, with

[jackson-user] Interest in a closed `jackson-security` discussion group?

2018-04-06 Thread Tatu Saloranta
Related to recent discussion about various CVEs filed against Jackson (and fixed, released), I think there is need for specific forum for discussing security issues related to Jackson. Since existing mailing groups are fully archived and open to anyone (although I do have moderation rights to

Re: [jackson-user] non blocking JSON parser optimized for UTF-8 stream

2018-04-06 Thread Tatu Saloranta
On Fri, Apr 6, 2018 at 2:59 PM, Xiao Ma wrote: > Hi, > > The NonBlockingJsonParser introduced in 2.9 is very useful. However, it > doesn't provide the optimization for UTF-8 encoding as in > UTF8StreamJsonParser. Is there a plan to provide a non-blocking JsonParser > with UTF-8

Re: [jackson-user] Jackson 2.9.5 case sensitive problem

2018-04-06 Thread Tatu Saloranta
Ok, couple of notes: 1. Jackson does not know or care about XSD: the only thing that matters is generated Java class(es) 2. If using JAXB annotations, make sure to register JAXBAnnotationIntrospector: by default Jackson only uses its own annotations; but `AnnotationIntrospector` allows

Re: [jackson-user] Backports of CVE-2017-7525

2018-04-06 Thread Tatu Saloranta
On Wed, Apr 4, 2018 at 9:43 PM, 'Michael Yoder' via jackson-user <jackson-user@googlegroups.com> wrote: > On Wed, Apr 4, 2018 at 6:30 PM, Tatu Saloranta <t...@fasterxml.com> wrote: >> >> This sounds like useful for many users. Thank you for sharing! > > >

Re: [jackson-user] Custom Deserializer

2018-04-09 Thread Tatu Saloranta
Do you think `@JsonAnySetter` would work here, attached to Map? It would get all values that do not map to existing regular properties? It wouldn't do anything for underscores but would allow easy collection. Or, if you want to strip underscore, you could specify method instead @JsonAnySetter

Re: [jackson-user] Deep Copy using Jackson: String or JsonNode

2018-04-20 Thread Tatu Saloranta
On Fri, Apr 20, 2018 at 7:06 AM, Rad Akefirad wrote: > Hi, > > I asked this question on SO and to my surprise I didn't get any answer. Is > there anyone here know the answer. > Thanks in advance. > > Regards, > Rad > > PS: the post is: > >> Objective: deep copy (or clone) of a

Re: [jackson-user] Access objectMapper from custom JsonSerializer to call valueToTree

2018-04-16 Thread Tatu Saloranta
On Mon, Apr 16, 2018 at 11:02 AM, Marcel Overdijk wrote: > Thanks Tatu! > > Another option I was thinking of was > > 1) creating the object mapper > 2) creating the serializer (and provide the created objectmapper to the > serializer e.g. via the serializers constructor) > 3)

Re: [jackson-user] Jackson: Serialise POJO using class method

2018-04-16 Thread Tatu Saloranta
Two standard features that could help: 1. If class implement `JsonSerializable`, its public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException; will be called to allow you to properly serialize it using generator that is property configured 2 If a method

Re: [jackson-user] Are custom serializers cached?

2018-04-16 Thread Tatu Saloranta
On Mon, Apr 16, 2018 at 11:07 AM, Marcel Overdijk wrote: > I don’t *require* only 1 instance but want to avoid that many are created as > I do need to do some introspection if classes and want to cache that > information. > It is only an annotation in class level so that

Re: [jackson-user] Is it possible to provide (request-based) context to a custom `JsonSerializer`?

2018-04-16 Thread Tatu Saloranta
On Sun, Apr 15, 2018 at 9:53 AM, Marcel Overdijk wrote: > Hi, > > Is it possible to provide (request-based) context to a custom > `JsonSerializer`? Like a `fieldsets` request param to remove some fields > from the generated json? > > Or is the best option to bind the needed

[jackson-user] Re: Interest in a closed `jackson-security` discussion group?

2018-04-19 Thread Tatu Saloranta
happen to find this message or original via googling, and think it'd be useful to have a new forum, speak up. I have plenty of other things to work on. -+ Tatu +- On Fri, Apr 6, 2018 at 3:23 PM, Tatu Saloranta <t...@fasterxml.com> wrote: > Related to recent discussion about various C

Re: [jackson-user] use jackson deserialize File from json cause an error

2018-04-24 Thread Tatu Saloranta
On Tue, Apr 24, 2018 at 1:48 AM, xiao tan wrote: > when i use jackson like this: > String json="{"path": > "/data/user/0/com.zhihu.android.mediastudio/files/mediastudio/2421cbc0-36c4-4b00-a8bd-f55e43bbb4bc/capture_1524547516358.mp4"}" > mapper.read(json,File.class); > > i got

Re: [jackson-user] Treat float-loke string as String

2018-04-24 Thread Tatu Saloranta
On Fri, Apr 20, 2018 at 4:38 AM, Svetlin Zarev wrote: > Hi, > > I have a YML file that looks like > > --- > - NAME: example > VERSION: 1.10 > > The problem is that ObjectMapper.readValue(source, java.util.Map.class) > treats the version as a floating point

Re: [jackson-user] Jackson cannot parse values with hexadecimal digits

2018-04-17 Thread Tatu Saloranta
On Mon, Apr 16, 2018 at 11:31 PM, wrote: > > > string with hexadecimal digits is valid, but jackson can not pase these > values. > Is there a solution or did i miss something? > > > Yes, you are tripped by javac :) You are not including

[jackson-user] Re: 2.9.5 release being started -- will take a while

2018-03-26 Thread Tatu Saloranta
On Mon, Mar 26, 2018 at 8:24 AM, Tatu Saloranta <t...@fasterxml.com> wrote: > As per title: I started releasing 2.9.5, but due to various things it > may take the whole day to get all components out (plus extra for Scala > as usual). So please do not report "jackson-x 2

Re: [jackson-user] Default all nulls to Empty Strings when Deserializing JSON field into a String field

2018-03-24 Thread Tatu Saloranta
On Sat, Mar 24, 2018 at 9:14 AM, Darius wrote: > I have a set of POJOs where all the fields are Strings. I am deserializing > JSON into the POJO, and the JSON can have some null values. > Is there a single setting that can make these nulls be deserialized as > strings,

[jackson-user] 2.9.5 release being started -- will take a while

2018-03-26 Thread Tatu Saloranta
As per title: I started releasing 2.9.5, but due to various things it may take the whole day to get all components out (plus extra for Scala as usual). So please do not report "jackson-x 2.9.5" missing unless it has been missing for more than a day, from this point on. -+ Tatu +- -- You

Re: [jackson-user] objectMapper.disable(MapperFeature.AUTO_DETECT_FIELDS) no longer works in 2.9.4

2018-03-21 Thread Tatu Saloranta
No intentional changes made; visibility detection should work as before. There is one fix scheduled for 2.9.5: https://github.com/FasterXML/jackson-databind/issues/1947 which could be related, but is not necessarily the same thing. If it is easy for you to locally test with 2.9.5-SNAPSHOT, that

Re: [jackson-user] jackson primer

2018-03-22 Thread Tatu Saloranta
You might try google, there is growing set of tutorials in the web... But aside from `jackson` portal, `jackson-docs`: https://github.com/FasterXML/jackson-docs is one collection we maintain. I don't think digging through code should be necessary, but with all due respect finding tutorials is

Re: [jackson-user] YAML 1.2 support

2018-03-19 Thread Tatu Saloranta
\On Thu, Mar 8, 2018 at 1:14 AM, Andrey Somov wrote: > Hi all, > I am willing to support YAML 1.2 (superset of JSON) in SnakeYAML and break > the backwards compatibility. > > Can somebody help me to form the high level API ? > What should be improved ? How ? > > The idea

Re: [jackson-user] Is there a jackson-databind version 2.9.3.1 ?

2018-03-19 Thread Tatu Saloranta
s. I hope this helps! -+ Tatu +- On Mon, Mar 19, 2018 at 9:41 AM, Tatu Saloranta <t...@fasterxml.com> wrote: > There is version `2.9.4` that has everything that hypothetical `2.9.3.1 > > On Mon, Mar 19, 2018 at 6:49 AM, Dajinsol Jeon <djeo...@gmail.com> wrote: >> Hi, >

Re: [jackson-user] Custom deserialization problem for Optional with specified values for Optional.empty()

2018-03-19 Thread Tatu Saloranta
Assuming you are talking about Java 8 Optional, and not alternatives from Guava or Scala, my first question is... why are you not using Java 8 module that provides support for it, `jackson-datatype-jdk8`? -+ Tatu +- On Mon, Mar 19, 2018 at 3:50 AM, cap5lut wrote: > Hi,

Re: [jackson-user] Is there a jackson-databind version 2.9.3.1 ?

2018-03-19 Thread Tatu Saloranta
There is version `2.9.4` that has everything that hypothetical `2.9.3.1 On Mon, Mar 19, 2018 at 6:49 AM, Dajinsol Jeon wrote: > Hi, > > Maybe it is really a dumb question, but is there a jackson-databind 2.9.3.1 > ? Or is there a plan for releasing it? > > I heard that in

Re: [jackson-user] Problem while converting JSON to POJO when the json contains characters like é

2018-03-16 Thread Tatu Saloranta
On Thu, Mar 15, 2018 at 11:44 PM, Vidyaranya Sai Nuthalapati wrote: > I have a java object which has fields like content and customerName. I > serialize this object which will be something like: > > {"customerName" : "Dummy customer", "content" : [{"author" : "Arthur

Re: [jackson-user] Compatibility between jackson-databind versions 2.8.10 --> and --> 2.8.11.1

2018-03-23 Thread Tatu Saloranta
On Fri, Mar 23, 2018 at 5:34 PM, Darius Cooper wrote: > Are there any known compatibility issues going from version 2.8.10 to > 2.8.11.1 ? > > We use jackson-databind indirectcly,through Camel. The last few versions of > Camel use jackson-databind v 2.8.10, which has a few

Re: [jackson-user] How to distinguish missing fields from null when using property-based JsonCreator?

2018-03-05 Thread Tatu Saloranta
On Mon, Mar 5, 2018 at 6:14 PM, wrote: > For bean setters we have > https://github.com/FasterXML/jackson-databind/issues/1402, which AFAICT > allows to specify different behaviour for nulls vs missing keys. > > I want to achieve the same but also preserve immutability (and

Re: [jackson-user] Safe deserialization

2018-10-05 Thread Tatu Saloranta
On Fri, Oct 5, 2018 at 9:28 AM Michael Rogers wrote: > Hi, > > I'd like to use Jackson to deserialize JSON from an untrusted source > into simple POJOs that can be used for further validation (checking that > values are within allowed ranges, etc). I've read a couple of blog posts > about

Re: [jackson-user] DoS attack about numbers

2018-10-16 Thread Tatu Saloranta
dd tests too, but this is tricky one to test... not sure how to automate since it is very difficult to automatically verify timing problems due to usual performance measurement challenges (JVM startup slowness etc). -+ Tatu +- > > 在 2018年10月16日星期二 UTC+8下午11:08:11,Tatu Saloranta写道: >> >>

Re: [jackson-user] Excluding empty/null fields in JsonGenerator

2018-10-21 Thread Tatu Saloranta
> > private static class NullExcludingTokenFilter extends TokenFilter { > > @Override > public boolean includeNull() { > return false; > } > > } Ah! I had forgotten there actually already was this quite specific filtering option!!! :-D Yes, that looks legit

Re: [jackson-user] @JsonTypeInfo and multiple levels of inheritance

2018-10-21 Thread Tatu Saloranta
where the "closes" `@JsonTypeInfo` is declared). > I will file a bug using this more realistic example as a reproducing case. That would be good, for the original case, where information is available but not properly used. Thanks! -+ Tatu +- > > lørdag 13. oktober 2018 23.26.3

Re: [jackson-user] Reusing JsonGenerator and FilteringGeneratorDelegate

2018-10-21 Thread Tatu Saloranta
On Sun, Oct 21, 2018 at 2:02 PM Volkan Yazıcı wrote: > > Hi, > > I have a JsonGenerator and FilteringGeneratorDelegate usage as follows: > > ByteArrayOutputStream outputStream = threadLocalOutputStreamRef.get(); > try (JsonGenerator jsonGenerator = jsonFactory.createGenerator(outputStream)) > {

Re: [jackson-user] Deserializing multiple neted data structure

2018-10-21 Thread Tatu Saloranta
If the structure of your data and POJOs does not really match, databinding is not going to be easy, unfortunately. So often the best bet would be to first bind into intermediate representation, like JsonNode, then transform it to a structure that is compatible with POJO, and use

Re: [jackson-user] DoS attack about numbers

2018-10-17 Thread Tatu Saloranta
On Tue, Oct 16, 2018 at 5:59 PM wjm wjm wrote: > > 在 2018年10月17日星期三 UTC+8上午12:54:52,Tatu Saloranta写道: >> >> On Tue, Oct 16, 2018 at 9:50 AM wjm wjm wrote: >>> >>> >>> 1/2. "too big" or "too small" number, maybe should throw

Re: [jackson-user] Excluding empty/null fields in JsonGenerator

2018-10-13 Thread Tatu Saloranta
On Sat, Oct 13, 2018 at 1:22 PM Volkan Yazıcı wrote> > While using `JsonGenerator`, how can I exclude empty/null/blank object fields? > > (I have asked the very same question on SO as well, but could not get any > answer yet. Hence the cross-post.) By not writing them. That is, generator

Re: [jackson-user] @JsonTypeInfo and multiple levels of inheritance

2018-10-13 Thread Tatu Saloranta
On Fri, Oct 12, 2018 at 7:12 AM Jan-Olav Eide wrote: > > Using Jackson 2.9.6, i came across the following, which to me looks like a > bug. Abstract superclass A has two subclasses, B and C, where B again has a > subclass D > > Adding the @JsonTypeInfo and @JsonSubTypes annotations as shown

Re: [jackson-user] DoS attack about numbers

2018-10-16 Thread Tatu Saloranta
On Tue, Oct 16, 2018 at 8:02 AM wjm wjm wrote: > > seems that jackson have some problems when parse super number > Gson failed at once, but jackson block long times and then failed > because jackson parse the super number to BigInteger first and then convert > to target number type. > > i write

Re: [jackson-user] Json deep merge array processing strategy

2018-10-28 Thread Tatu Saloranta
Merging for arrays does mean concatenation (append for Collections), and nothing else. This because while there are many possible ways users might want to handle merging of two sequence values, it is surprisingly difficult to figure out declarative way that covers enough without being very

Re: [jackson-user] Reusing JsonGenerator and FilteringGeneratorDelegate

2018-10-25 Thread Tatu Saloranta
rom processing perspective. -+ Tatu +- > > Best. > > On Monday, October 22, 2018 at 6:59:02 AM UTC+2, Tatu Saloranta wrote: >> >> On Sun, Oct 21, 2018 at 2:02 PM Volkan Yazıcı wrote: >> > >> > Hi, >> > >> > I have a JsonGenerator an

Re: [jackson-user] Combine Jackson mixing with ValueInstantiator

2018-10-23 Thread Tatu Saloranta
On Mon, Oct 22, 2018 at 9:55 AM lev wrote: > > I posted this question on SO, but it didn't get much attention, so I'm > posting here as well. > > - > > > I'd like to deserialize the following class: > > case class Target( >a: Option[Long], >b: String >

Re: [jackson-user] Reusing JsonGenerator and FilteringGeneratorDelegate

2018-11-05 Thread Tatu Saloranta
On Friday, October 26, 2018 at 3:57:38 AM UTC+2, Tatu Saloranta wrote: >> >> On Wed, Oct 24, 2018 at 5:35 AM Volkan Yazıcı wrote: >> > >> > I am at the edge of making log4j2-logstash-layout gc-free. And at >> > this stage my only (GC) obstacle is the afo

Re: [jackson-user] streaming from JsonParser to JsonGenerator

2018-11-12 Thread Tatu Saloranta
You may be looking for `JsonGenerator.copyCurrentEvent(parser)` (or `copyCurrentStructure(parser)`) method -+ Tatu +- On Sun, Nov 11, 2018 at 7:51 PM Niels Bertram wrote: > > I am trying to stream JSON data read by a JsonParser to a JsonGenerator. Has > anyone ever come across an example

Re: [jackson-user] ObjectNode.get("foo") should return MissingNode when field "foo" does not exists

2018-11-02 Thread Tatu Saloranta
On Fri, Nov 2, 2018 at 2:19 PM Federico Fissore wrote: > > Hi all > > Given this code snippet > > String json = "{\"bar\": null}"; > > JsonNode jsonNode = new ObjectMapper().readTree(json); > > System.out.println(jsonNode.get("bar").asText("banana 1")); > >

Re: [jackson-user] Generate XSD from Java class

2018-10-04 Thread Tatu Saloranta
On Tue, Oct 2, 2018 at 10:34 PM wrote: > > Hi, > > Is there a simple way to generate XSD from a Java class? > > I successfully generated JSON with Jackson Module JsonSchema but I didn't > found how to do it with XSD (no module existing ?). > I would like to be able to to it like in JSON, see

Re: [jackson-user] Why isn't there a public way to write a byte[] in JsonGenerator?

2018-10-02 Thread Tatu Saloranta
On Tue, Oct 2, 2018 at 10:34 PM Nilson Santos Figueiredo Jr. wrote: > > Hi, > > I have a particular use-case where we're trying to optimize some code which > uses Jackson to generate less garbage. > The desired outcome here is to do something similar to what >

Re: [jackson-user] The correct way to serialize / deserialize a Map to / from XML

2018-09-27 Thread Tatu Saloranta
On Thu, Sep 27, 2018 at 10:29 PM Tristan Lins wrote: > I need to serialize / deserialize a Map to / from XML with > dataformat-xml / XmlMapper. > > It works fine with JSON when using default typing. > But when deserialize the XML, the typing of primitive types (especially > numeric and boolean)

Re: [jackson-user] Safe deserialization

2018-10-10 Thread Tatu Saloranta
tching id), nor does `java.io.Serializable`. Use of annotations other than `@JsonTypeInfo` does not enable unsafe handling either. -+ Tatu +- > > Thanks again, > Michael > > On 05/10/2018 17:41, Tatu Saloranta wrote: > > On Fri, Oct 5, 2018 at 9:28 AM Michael Rogers >

Re: [jackson-user] Why @class value is required in my JSON String

2018-10-10 Thread Tatu Saloranta
What is likely happening is that your type has `@JsonTypeInfo` annotation which enables polymorphic handling (and if not declared on POJO, maybe via mix-in annotations?), and for that some type of type id is absolutely required. Question, then, is why POJO type has that annotation. Alternative

Re: [jackson-user] The correct way to serialize / deserialize a Map to / from XML

2018-10-10 Thread Tatu Saloranta
ransformation of the map. > > Thank you very much for your feedback! Sorry I couldn't be of much more help. XML is tricky, but I hope you can get things to work. -+ Tatu +- > > Am Freitag, 28. September 2018 07:32:45 UTC+2 schrieb Tatu Saloranta: >> >> On Thu, Sep 27, 20

Re: [jackson-user] Multiple Mixins in one class?

2018-10-10 Thread Tatu Saloranta
On Tue, Oct 9, 2018 at 5:13 PM Ygor Castor wrote: > > Hello, i'm having a problem with a scenario, i've created the following Mixin > that is responsible to append a property in every object passed through the > object mapper: > > @JsonAppend( > prepend = true, > props = { >

Re: [jackson-user] Re: Custom output format with JSON Schema Module

2018-10-10 Thread Tatu Saloranta
On Wed, Sep 12, 2018 at 11:46 PM 'Gunnar Morling' via jackson-user wrote: > > This got stuck in the moderation queue for a while, in between I've found a > solution. > > For those interested, I'm using custom extensions of IntegerSchema etc. > (exposed via a custom JsonSchemaFactory) which

Re: [jackson-user] setSerializationInclusion(Include.NON_EMPTY) seems to not exclude nulls in arrays?

2018-09-22 Thread Tatu Saloranta
On Fri, Sep 21, 2018 at 11:37 AM Broly1 wrote: > > Hi all first time using java object to Json conversion. > > I'm trying to have the output (Json) not include any null values. > > I've tried the following. > objectMapper.setSerializationInclusion(Include.NON_NULL); >

Re: [jackson-user] Support for getting precision in double e.g "Balance": 25000.00

2018-09-26 Thread Tatu Saloranta
On Tue, Sep 25, 2018 at 4:42 PM ASHWINI RAI wrote: > > Hi Everyone, > > I have written a custom deserializer for my application. My api spec has > "Balance" field and it is defined as double. But when I return this from my > api using jackson 2.9.0 I want 25000 to be returned as 25000.00 and

Re: [jackson-user] Is it possible to do conditional serialization in jackson?

2018-09-25 Thread Tatu Saloranta
On Mon, Sep 24, 2018 at 12:06 PM gaurav wrote: > > is it possible to do conditional serialization in jackson? > > i.e. if @JsonView is applied on few fields, then serialize them else > serialize whole bean. I am not sure I follow -- that sounds like how `@JsonView` works? Although the behavior

Re: [jackson-user] date format issue in Jackson

2018-09-25 Thread Tatu Saloranta
On Wed, Sep 19, 2018 at 11:13 AM wrote: > > As I know springboot uses jackson. I try to update my project's springboot > version from 1.5.1 to 2.0.1. And I find the date format is different in that > two versions. > > public class Message { > private Instant instant; > > } > > > In

Re: [jackson-user] Is there any way to let jackson to dyanmically write sub type name during serialization?

2018-09-25 Thread Tatu Saloranta
On Mon, Sep 24, 2018 at 12:06 PM Wayne Tech wrote: > > Hi, > > I was trying to find a solution to let jackson to serialize without an extra > super type element. > > I have a class that has an instance of a super type > > A.java > { > SuperType superType; > // other object definitions >

Re: [jackson-user] Deserializer priority?

2018-12-29 Thread Tatu Saloranta
On Sat, Dec 29, 2018 at 3:01 PM Mike Summers wrote: > > I have a Spring Boot (2.1.1) app that is modeling ActivityStreams objects and > for the most part Jackson's (2.9.7) Polymorphic Deserialization works well. > > > There are 'objects' in the JSON which are references (links) and not JSON >

Re: [jackson-user] class level JsonSerializable vs Method level

2019-01-02 Thread Tatu Saloranta
mething that is supported (it's not accidental), but different from more common approach of simply using serializer for known type like `String`. -+ Tatu +- > On Monday, December 24, 2018 at 4:56:27 PM UTC-8, Tatu Saloranta wrote: >> >> On Fri, Dec 21, 2018 at 2:30 P

Re: [jackson-user] how to convert a xml string to java list with xmlmapper?

2019-01-02 Thread Tatu Saloranta
On Wed, Jan 2, 2019 at 8:39 AM <915702...@qq.com> wrote: > i have a xml string like this: > >123 > 456 > > > how to i got List a or more generally List if the > element has child element? > > > The general way to figure out how (and if -- Jackson does NOT guarantee it can deserialize

Re: [jackson-user] jackson-databind-2.6.7.2

2018-12-20 Thread Tatu Saloranta
10:10:15 PM UTC-5, Tatu Saloranta wrote: >> >> On Tue, Dec 11, 2018 at 7:04 PM garvit singh wrote: >> > >> > Hello, >> > >> > jackson-databind-2.6.7.2 >> > >> > >> > does it have fix for >> > >> > CVE-

Re: [jackson-user] JsonGenerationException with custom serializers for nested object

2018-12-20 Thread Tatu Saloranta
I think the problem is here: On Thu, Dec 20, 2018 at 11:32 AM matt Smith wrote: > > here is the class that I want to serialize. > > > public class ItemRow { > > private String id; > private List items; > } > > >There are two variations that are allowed. > > `ItemRow,

Re: [jackson-user] class level JsonSerializable vs Method level

2018-12-20 Thread Tatu Saloranta
On Thu, Dec 20, 2018 at 11:22 AM matt Smith wrote: > > I encountered a case where class level JsonSerializable annotation does not > require registration with Simple Module but method level does. Hmmh. This seems odd, let's see. > Here is the example I tried > > @JsonSerialize(using =

Re: [jackson-user] Re: JsonGenerationException with custom serializers for nested object

2018-12-20 Thread Tatu Saloranta
SON values, not fragments, otherwise delegation will not work. Your own code can of course compose things using other patterns, but you should then structure your code in way that matches that. I hope this helps, -+ Tatu +- > > > On Thursday, December 20, 2018 at 1:44:45 PM UTC-

Re: [jackson-user] Re: Recursive serializers and deserializers using jackson is not working as expected

2018-12-20 Thread Tatu Saloranta
I think you should not recursively call `serialize()` with `getArgs()`, if you do not want values wrapped as JSON Objects. You probably need to refactor code a bit, so that outermost cases outputs full Object, args case just appends name/value pairs. Also one simplification I suggest is that

Re: [jackson-user] class level JsonSerializable vs Method level

2018-12-21 Thread Tatu Saloranta
return foo; > } > > > public void setFoo(Map foo) { > this.foo = foo; > } > } > > > On Thursday, December 20, 2018 at 1:25:59 PM UTC-8, Tatu Saloranta wrote: >> >> On Thu, Dec 20, 2018 at 11:22 AM matt Smith wrote: >> > >> &g

Re: [jackson-user] Cyclic Object Graph Serialization

2018-12-11 Thread Tatu Saloranta
On Tue, Dec 11, 2018 at 7:04 PM Denis Mouraviev wrote: > > Hello, > > i need to serialize cyclic object graph, i dont own those pojos, so > annotations are not the way to go. > I guess i need to write a custom serializer for that. The problem is there a > lot of different types in that graph. >

Re: [jackson-user] jackson-databind-2.6.7.2

2018-12-11 Thread Tatu Saloranta
On Tue, Dec 11, 2018 at 7:04 PM garvit singh wrote: > > Hello, > > jackson-databind-2.6.7.2 > > > does it have fix for > > CVE-2018-7489 > CVE-2017-17485 No; these are Jackson-databind issues #1931 (CVE-2018-7489) and #1855 (CVE-2017-17485), and only included in patches for 2.7(.9.3) and later.

Re: [jackson-user] class level JsonSerializable vs Method level

2018-12-24 Thread Tatu Saloranta
ve annotated class ItemRow class which ofcourse i can't since it is >> part of legacy code. >> >> On Friday, December 21, 2018 at 12:49:21 PM UTC-8, Tatu Saloranta wrote: >>> >>> On Fri, Dec 21, 2018 at 12:06 AM matt Smith wrote: >>> > >&g

Re: [jackson-user] class level JsonSerializable vs Method level

2018-12-24 Thread Tatu Saloranta
ample https://dzone.com/articles/jackson-mix-in-annotations -+ Tatu +- > > On Friday, December 21, 2018 at 12:49:21 PM UTC-8, Tatu Saloranta wrote: >> >> On Fri, Dec 21, 2018 at 12:06 AM matt Smith wrote: >> > >> > so I have made this wrapper and annotated

Re: [jackson-user] Deserialize JSON string to Map

2018-12-04 Thread Tatu Saloranta
ame\", " + > "\"activeDate\":\"26-09-2017 11:00:00\"}"; > > > but does not work when I have nested json objects. E.g. : {"a":"b", "c":{ > > "d":"1"}, "z":["1"] } >

Re: [jackson-user] Deserialize JSON string to Map

2018-12-05 Thread Tatu Saloranta
: >> \"Name\", " + >> "\"activeDate\":\"26-09-2017 11:00:00\"}"; >> >> >> but does not work when I have nested json objects. E.g. : {"a":"b", "c":{ >> >> "d"

Re: [jackson-user] java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.ObjectMapper in Java 11

2018-12-05 Thread Tatu Saloranta
On Tue, Dec 4, 2018 at 10:45 AM Dvir L wrote: > > We are using Jackson 2.8.5.tr1 (jackson-databind, jackson-core, > jackson-annotations) within our jar file and it works fine using Java 8. When > trying to run our jar file using Java 11, we are getting a runtime exception - > > Caused by:

<    1   2   3   4   5   6   7   8   >