Ok. So, based on earlier email, feedback, I think 2 questions can be rephrased:

1. How to name accessor for globally-shared, default-configured
ObjectMapper instance

   - Usage intended for things like "define `toString()` to return
default JSON serialization of object" and "just read JSON into
`JsonNode` / `Map` for simple data extraction" and "write Map into
json"

    Right now I think that "instance()" would not be optimal because
while it is commonly used, it is used in cases where global singleton
is the only option. But here it is actually one of the options.
   As pointed out by Michel, other names I suggested (esp.
"vanilla()") do not convey idea of what method does. But I think
"shared()" might work better:

   String json = JsonMapper.shared().writeValueAsString(pojo);
    // note: 3.0 provides format-specific mappers as starting point for builders
    // note: with 3.0 mapper instances can not be changed at all -- but one can
    // create copies with "mapper.rebuild()", via builder initialized
to settings of an instance

 I am open for even better ideas, but for now I consider this the
leading candidate

2. On creating ObjectReader/ObjectWriter instances that do not throw
checked exceptions
   (that is, IOException and sub-types like JsonMappingException)

There is a choice to make here: we could, theoretically, make this
happen for 2.10; or only for 3.0.
Another choice is that of:

(a) Change `JsonProcessingException` to extend `RuntimeException`
(b) Allow construction of ObjectReader/ObjectWriter subtype (with
method like `reader.unchecked()` or `reader.safe()`), with API
("SafeObjectReader") that overrides method and drops exception
declaration

But while we can select either of choices for both of them, not all
combinations are possible for all Jackson versions: (a) is only
available with Jackson 3.0 as it drastically changes behavior
regarding catch clauses -- anything that catches "IOException" would
NOT catch `JsonProcessingException` if we change the base type.

So. questions then become:

1. Are we ok with not having convenient processing wrt exceptions with
2.10 (I am guessing that is fine since, well, that's the current
state), or would we rather get something for 2.10?
2. If we want to keep JsonProcessingException a subtype of
IOException, how would we name accessor method and subtype?

On (2), access itself would be via ObjectReader/ObjectWriter instance,
which would create a new instance initially, but repeated calls would
just return `this`. So, something like:

   // following will never throw checked exception
   String json = mapper.readerFor(Pojo.class).safe().readValue(input);

and actual subtype name is only needed if the reference is needed for
multiple calls:

   SafeObjectReader r = standardReader.safe();

At the end of the day I guess I am now leaning towards waiting for
3.0, and changing base class of JsonProcessingException. It would
require bit more code for streaming API, and some restructuring of
subtypes (namely: start wrapping raw IOExceptions as either JDK
UncheckedIOException, or as newly created JsonIOException), but
overall would be simpler to use and understand. And it would also be
usable with `ObjectMapper`, not just ObjectReader/-Writer.

But. If there is strong feeling that it'd be really great to get more
convenient stream-oriented/functional usage for Jackson 2.x, I can be
convinced otherwise.

-+ Tatu +-

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to