Skip to content

Commit

Permalink
Merge missing part of Record deserialization support for 3.0/master
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jun 14, 2024
1 parent 9b1ea9b commit 56afb8e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions jr-objects/src/main/java/tools/jackson/jr/ob/impl/BeanReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<Object> 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();
Expand Down

0 comments on commit 56afb8e

Please sign in to comment.