JsonJacksonApprovals should accept instance of ObjectMapper
The org.approvaltests.JsonJacksonApprovals class should accept ObjectMapper as an optional parameter, similarly to the org.approvaltests.JsonApprovals accepting a Function1<GsonBuilder, GsonBuilder> gsonBuilder.
The main motivation is to have consistent serialization with the rest of the application, allowing to perform pretty-printing without changing the semantics of the output (typically NULL values present vs missing).
I don't think there is any reason to modify the mapper during verification, therefore I find it safe to pass the actual instance instead of some ObjectMapper factory/builder.
Thank you for the tooling! I really appreciate such a zero-config snapshotting functionality :)
Since Jackson supports ordering of properties and map entries out of the box (ORDER_MAP_ENTRIES_BY_KEYS, SORT_PROPERTIES_ALPHABETICALLY options), allowing to pass an instance of ObjectMapper will make the JsonJacksonApprovals implementation on par with JsonApprovals in terms of features.
A simple solution would is to simply define the ObjectMapper as a public static field in the class. That on each JsonJacksonApprovals.asJson a new ObjectMapper instance is created is wasteful anyway.
A more elegant approach would be to use the approach by java-snapshot-testing