mongo-jackson-mapper

Ignore field with annotation for JSON serialization but not for Mongo in MongoJack


Is there any possibility to ignore field for JSON serialization (for web display) but not for mongo (internal serialization) ?

I`ve tried so far all these methods but field was also ignored for Mongo, or not ignored in both in case of some variations

Jackson: how to prevent field serialization


Solution

  • Ok, I finally solved this.

    objectMapper.writerWithView(Views.Public.class).writeValueAsString(lo)); 
    

    writeValueUsingView is from another version of Jackson, so it wasn't working