I think it is the expectation of johnzon, the record model is to use getters without "get",
using lombok the additional properties are actually matching this so end in the json what i'm no more sure is about builder one, if static we should clearly filter static methods out but age must be in the json IMHO otherwise you loose the hability to have "virtual" read only properties which is an important feature IMHO (similarly of what we were doing with POJO). Romain Manni-Bucau @rmannibucau <https://x.com/rmannibucau> | .NET Blog <https://dotnetbirdie.github.io/> | Blog <https://rmannibucau.github.io/> | Old Blog <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> | LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book <https://www.packtpub.com/en-us/product/java-ee-8-high-performance-9781788473064> Le mer. 2 juil. 2025 à 15:58, Jean-Louis Monteiro <jlmonte...@tomitribe.com> a écrit : > I will update my version, but long story short, the following does not work > > @Test > > public void foo() { > > try (Jsonb jsonb = ....) { > > final Person person = new Person("John Doe", LocalDate.of(1990, > 1, 1)); > > final String json = jsonb.toJson(person); > > assertEquals("{\"name\":\"John > Doe\",\"birthday\":\"1990-01-01\"}", json); > > > > final Person deserializedPerson = jsonb.fromJson(json, > Person.class); > > assertEquals("John Doe", deserializedPerson.name()); > > assertEquals(33, deserializedPerson.age()); > > } catch (Exception e) { > > throw new RuntimeException(e); > > } > > } > > > > @Builder(builderClassName = "Builder") > > public record Person (String name, LocalDate birthday) { > > public int age() { > > return LocalDate.now().getYear() - birthday.getYear(); > > } > > } > > > > > > > The JSON would contain 2 additional nodes > > "builder":{}, > > > > > "age": 33 > > > I've updated the MethodAccessMode to filter out methods which are not > fields > > if (isRecord(clazz) || Meta.getAnnotation(clazz, JohnzonRecord.class) != > null) { > readers.putAll(Stream.of(clazz.getMethods()) > .filter(it -> it.getDeclaringClass() != Object.class && > it.getParameterCount() == 0) > .filter(it -> clazz.getRecordComponents() == null > || > java.util.Arrays.stream(it.getDeclaringClass().getRecordComponents()) > .anyMatch(rc -> rc.getName().equals(it.getName()) > && > rc.getType().equals(it.getReturnType()))) > .filter(it -> !"toString".equals(it.getName()) && > !"hashCode".equals(it.getName())) > .filter(it -> !isIgnored(it.getName()) && > Meta.getAnnotation(it, JohnzonAny.class) == null) > .collect(toMap(m -> extractKey(m.getName(), m, null), it -> > new MethodReader(it, it.getGenericReturnType())))); > } else { > > > > But again, it might be something with my project if you think it's all ok. > > -- > Jean-Louis Monteiro > http://twitter.com/jlouismonteiro > http://www.tomitribe.com > > > On Wed, Jul 2, 2025 at 2:14 PM Romain Manni-Bucau <rmannibu...@gmail.com> > wrote: > > > Hi JL, > > > > No strong opinion but records are supported since day 1 by johnzon so not > > sure I get right the last part of your mail. > > > > Romain Manni-Bucau > > @rmannibucau <https://x.com/rmannibucau> | .NET Blog > > <https://dotnetbirdie.github.io/> | Blog <https://rmannibucau.github.io/ > > > > | Old > > Blog <http://rmannibucau.wordpress.com> | Github > > <https://github.com/rmannibucau> | LinkedIn > > <https://www.linkedin.com/in/rmannibucau> | Book > > < > > > https://www.packtpub.com/en-us/product/java-ee-8-high-performance-9781788473064 > > > > > > > > > Le mer. 2 juil. 2025 à 12:51, Jean-Louis Monteiro < > > jlmonte...@tomitribe.com> > > a écrit : > > > > > Hi all, > > > > > > Anyone against bumping the java version for the main branch from 11 to > 14 > > > (or even 17)? > > > Currently, Java Record aren't really well managed and I don't think > using > > > Java Reflection to workaround the Java version is the best design. > > > > > > > > > -- > > > Jean-Louis Monteiro > > > http://twitter.com/jlouismonteiro > > > http://www.tomitribe.com > > > > > >