On Mon, Jul 27, 2020 at 1:15 AM <[email protected]> wrote:
>
> On 2020-07-26T16:05:44 -0700
> Tatu Saloranta <[email protected]> wrote:
> >
> > Tree model (JsonNode / ObjectNode) is meant to represent JSON content
> > exactly as-is, with few if
> > any transformations, and is handled quite differently from POJOs.
> > As such there is no auto-sorting feature at this point, although there
> > are some plans to maybe add support:
> >
> > https://github.com/FasterXML/jackson-future-ideas/wiki/JSTEP-3
> >
> > However: you should be able to convert `ObjectNode` into `Map` (or
> > just `Object` more generally) with
> >
> > Map<String, Object> map = mapper.treeToValue(node, Map.class);
> >
> > after which `SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS` should
> > work on serialization.
> > So 2-step processing should handle this particular case.
>
> Hello!
>
> Does `treeToValue` handle nested ObjectNodes? I'm actually implementing

Yes, it should work recursively; it is full "convertValue()" just with
input value restriction.

> JSON canonicalization [0]. In Jackson right now, serialization without
> indentation fulfills all of the requirements of canonicalization except
> for the sorting of keys on serialization.

Ah. It might make sense to file an RFE issue asking for sorting of
ObjectNode entries as this seems like
a legit use case. As I mentioned it is sort of on my radar as wish,
but as part of bunch of other "JsonNode features".
Sometimes a separate issue makes it easier to prioritize such features.

> I can certainly walk the entire tree myself, but I'd prefer not to have
> to. :)

Yes, makes sense.

>
> [0]https://tools.ietf.org/id/draft-rundgren-json-canonicalization-scheme-00.html

-+ Tatu +-

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" 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-user/CAL4a10jj6F9Fzfz_2pJY04SkFoN%3D%3DsLrnxRu%3DB%2BQ-ub5TBKntA%40mail.gmail.com.

Reply via email to