Skip to content

[QUESTION] Alternatives of jackson's JsonSerialize.contentAs and writeValueAsView #3335

@blonded04

Description

@blonded04

Hello, I'm migrating a big spring5 project from jackson to fastjson2, and I'd like to ask how can I do the following:

  1. Specify, that Map<String, MyClass> field's MyClass'es values must be serialized as a MyClass, not as any of it's inheritors. In jackson I can do @JsonSerialize(contentAs = MyClass.class)
  2. Pass a flag custom flag to JSONWriter when writing to it, that I can further check and if it's present I use custom serialization (for example, sometime I'd like to serialize String password not as it's value, but as a *** when some flag was set to JSONWriter

Are there built-in ways to do it? If no, are there any workarounds?

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixedquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions