Hi! It has been a while since I have added a new foundational
functional, especially something related to bigger efforts, JSTEPs
(https://github.com/FasterXML/jackson-future-ideas/wiki/JSTEP).

But today I wanted to share my recent work on JSTEP-7
(https://github.com/FasterXML/jackson-future-ideas/wiki/JSTEP-7).
Basically, it is now possible to easily add new set of core on/off
feature flags -- not unlike DeserializationFeature,
SerializationFeature, wrt changing, checking etc -- but that apply to
a tighter set of things: to one specific class of datatypes.
This work was done under issue DB#3405:

    https://github.com/FasterXML/jackson-databind/issues/3405

----

Now, to give an actual idea of what this means, consider something I
completed today: addition of "JsonNodeFeature" -- something that
changes how "tree values" (JsonNode) are read and written -- along
with the very first concrete feature flag,

    JsonNodeFeature.READ_NULL_PROPERTIES

   https://github.com/FasterXML/jackson-databind/issues/3421

By default this is enabled, so JSON like:

{ "value" : null }

will be represented, when read, as an `ObjectNode` with one property,
with key of "value", value of `NullNode`.

But if this feature is disabled like so:

        ObjectMapper noNullsMapper = JsonMapper.builder()
                .disable(JsonNodeFeature.READ_NULL_PROPERTIES)
                .build();
        // or
        ObjectReader r = mapper.without(JsonNodeFeature.READ_NULL_PROPERTIES);

result would be same as if reading JSON like:

{ }

-----

Ok so why is this a big deal? Because from implementation perspective,
adding new Enum values in `JsonNodeFeature` or `EnumFeature` is very
simple; and checking value from deserializer/serializer is as simple
as (this from `JsonNodeDeserializer`)

---
                if (!ctxt.isEnabled(JsonNodeFeature.READ_NULL_PROPERTIES)) {
                    continue;
                }

---

it will now be much easier to add kind of configurability that has
been requested.

But beyond this, adding new Feature enums itself is relatively easy.
There are limitations,
of course -- there is no per-Module pluggability, for example, this is
for relatively general datatype classes (and mostly for
jackson-databind itself, but not exclusively esp for potential
`DateTimeFeature`) -- but this opens up many new possibilities.

On very short term at least we can tackle specifically JsonNode and
Enum read/write aspects, as per JSTEP-7.

Contributions welcome!

-+ 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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jackson-dev/CAL4a10jNS3fhjp4v7E%3DozOSMzWj1sxdn5AJ_ft5g2yajO88ujA%40mail.gmail.com.

Reply via email to