[jackson-user] WRAP_ROOT_VALUE when serializing

2017-03-20 Thread shane lee
Hi all, I have asked this question already on github: https://github.com/FasterXML/jackson-databind/issues/1567 What I want is to enable this serilisation feature but only for the pojo i have defined using @JsonRootName. Not all other pojos that i serialise. How is that possible? Thanks,

Re: [jackson-user] Re: How to access default serializer when writing custom serialiser

2017-03-20 Thread Tatu Saloranta
Good luck! That approach is used quite a lot so it should work fine. Note, too, that it may be combined with ContextualSerializer if you do need to access annotations. In fact you can use `createContextual()` sometimes to simply decide if override is needed at all; if not, return default

Re: [jackson-user] Re: How to access default serializer when writing custom serialiser

2017-03-20 Thread Zsolt Balanyi
Hi! OK, thanks, then I'll go that way! BR, Zsolt 2017. március 20., hétfő 20:13:25 UTC+1 időpontban Tatu Saloranta a következőt írta: > > This can not be done from annotation-based serializer: it will > override default logic. > The only way to access what would otherwise be created/used as

Re: [jackson-user] How to use type name as element name

2017-03-20 Thread Tatu Saloranta
Have you tried choice of `JsonTypeInfo.As.WRAPPER_OBJECT`? That does add type id as property-name "wrapper" in JSON, and should work quite similarly with XML. The main problem with XML is often, however, that the root value requires additional extra XML element. -+ Tatu +- On Mon, Mar 20, 2017

Re: [jackson-user] Re: How to access default serializer when writing custom serialiser

2017-03-20 Thread Tatu Saloranta
This can not be done from annotation-based serializer: it will override default logic. The only way to access what would otherwise be created/used as the standard serializer is to register `BeanSerializerModifier`, and override handling of `modifySerializer`. -+ Tatu +- On Mon, Mar 20, 2017 at

Re: [jackson-user] Re: How to access default serializer when writing custom serialiser

2017-03-20 Thread Zsolt Balanyi
Hi! What I meant is that I would like to get (or create ) the default Jackson Serializer for the object being serialized, and store as default. Then I could implement serialize as follows: @Override public void serialize(Object o, JsonGenerator jg, SerializerProvider sp) throws IOException {

Re: [jackson-user] How to use type name as element name

2017-03-20 Thread Zsolt Balanyi
Hi! public class Page { public UIElement uiElement; } @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") public abstract class UIElement { } public class StackLayout extends UIElement { public List uiElements = new ArrayList<>(); }

Re: [jackson-user] Jackson CSV: Edit header at first row of csv

2017-03-20 Thread Tatu Saloranta
Ok so what do you mean by "edit"? Change the effect taken, or to modify file from which data comes? Or something else? -+ Tatu +- On Fri, Mar 17, 2017 at 9:50 PM, Public Share wrote: > Hi, > > > I'm using jackson csv to write csv file. > But the header is mapping

Re: [jackson-user] How to use type name as element name

2017-03-20 Thread Tatu Saloranta
What is the POJO you are serializing? -+ Tatu +- On Mon, Mar 20, 2017 at 5:11 AM, Zsolt Balanyi wrote: > Hi! > > I have a structure that outputs this: > > > > > > > > > I use @JsonTypeInfo(use=JsonTypeInfo.Id.NAME, include=As.PROPERTY, >

Re: [jackson-user] Re: How to access default serializer when writing custom serialiser

2017-03-20 Thread Tatu Saloranta
Not 100% sure I understand the question, but if you want to access information about annotations on property, from your custom serializer, you need to implement `ContextualSerializer`, and then its `createContextual()` gets called with `BeanProperty`. `BeanProperty` has accessors for annotation

Re: [jackson-user] Limiting object depth and collection length during serialization for 3rd party classes

2017-03-20 Thread Tatu Saloranta
I hope someone who has had similar issue can share how they implemented limitations. -+ Tatu +- On Wed, Mar 15, 2017 at 9:40 PM, wrote: > Thanks for the quick reply. Are there workarounds to implement these? > > On Thursday, March 16, 2017 at 1:45:06 AM UTC+5:30, Tatu

[jackson-user] Re: How to access default serializer when writing custom serialiser

2017-03-20 Thread Zsolt Balanyi
Hi All! But what can I do when I want to use annotation, and I don't have access to the mapper? Eg: @JsonSerialize(using = ASerializer.class) public class AClass { ... } BR, Zsolt 2015. június 23., kedd 16:18:36 UTC+2 időpontban Tim Dudgeon a következőt írta: > > Hi, > > I'm writing a

[jackson-user] How to use type name as element name

2017-03-20 Thread Zsolt Balanyi
Hi! I have a structure that outputs this: I use @JsonTypeInfo(use=JsonTypeInfo.Id.NAME, include=As.PROPERTY, property="type") on the common base class. How could I get the following output: It does not matter, if it can not be deserialized by Jackson, it