Records to/from JSON
John Rose
john.r.rose at oracle.com
Thu May 7 21:48:13 UTC 2020
On May 7, 2020, at 2:35 PM, Alex Buckley <alex.buckley at oracle.com> wrote:
>
> A critical issue for the Jackson team seems to be detecting that a class is a record without using `Class::isRecord`, because it doesn't exist on Java 8. Multi-Release JARs, documented in JEP 238, would help Jackson here.
I don’t know how folks work around stuff like that today,
but I would think testing for the existence of java.lang.Record,
and then testing whether Record.class.isAssignableFrom(X),
is a pretty good workaround.
From there you need to discover the record components,
and that would seem to require either a MR-JAR or reflection
to finish the job.
I liked the write-up, too. The extra annotations were kind of
jarring to me also, even the ones mapping “foo bar” to “fooBar”.
But that’s a problem for Jackson to wrestle with, not a problem
with records. At least we’ve distanced ourselves requiring a
mapping from “name” to “getName”, which is a big deal to me.
— John
More information about the amber-dev
mailing list