diff --git a/jr-objects/src/main/java/tools/jackson/jr/ob/impl/BeanReader.java b/jr-objects/src/main/java/tools/jackson/jr/ob/impl/BeanReader.java index fc205790..ba8bc58d 100644 --- a/jr-objects/src/main/java/tools/jackson/jr/ob/impl/BeanReader.java +++ b/jr-objects/src/main/java/tools/jackson/jr/ob/impl/BeanReader.java @@ -31,6 +31,7 @@ public class BeanReader protected final BeanConstructors _constructors; + // @since 2.18 protected final boolean _isRecordType; // // 13-Dec-2017, tatu: NOTE! These will be constructed right after construction, but @@ -139,6 +140,29 @@ public BeanPropertyReader findProperty(String name) { public Object read(JSONReader r, JsonParser p) throws JacksonException { if (p.isExpectedStartObjectToken()) { + // [jackson-jr#148] Record deser support (2.18) + if (_isRecordType) { + final List values = new ArrayList<>(); + + String propName; + + // 13-Jun-2024, tatu: Should optimize the way _readBean() + // optimizes regular case... + for (; (propName = p.nextName()) != null;) { + BeanPropertyReader prop = findProperty(propName); + if (prop == null) { + handleUnknown(r, p, propName); + continue; + } + values.add(prop.getReader().readNext(r, p)); + } + try { + return _constructors.createRecord(values.toArray()); + } catch (Exception e) { + return _reportFailureToCreate(p, e); + } + } + final Object bean; try { bean = _constructors.create();