Skip to content

Commit

Permalink
Merge branch '2.18' into 2.19
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Oct 22, 2024
2 parents 8c76995 + d696133 commit 6429d03
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ public POJODefinition pojoDefinitionForSerialization(JSONWriter w, Class<?> pojo
private POJODefinition _introspectDefinition(Class<?> beanType,
boolean forSerialization, int features, boolean isRecord)
{
Map<String,PropBuilder> propsByName = new TreeMap<>();
// 21-Oct-2024, tatu: [jackson-jr#167] Need to retain property order
// for Deserialization, to keep Record properties ordered.
// For Serialization OTOH we need sorting (although would probably
// be better to sort after the fact, maybe in future)

Map<String,PropBuilder> propsByName = forSerialization ?
new TreeMap<>() : new LinkedHashMap<>();
_introspect(beanType, propsByName, features, isRecord);

final BeanConstructors constructors;
Expand Down Expand Up @@ -131,6 +137,10 @@ private static void _introspect(Class<?> currType, Map<String, PropBuilder> prop
}
if (Modifier.isPublic(f.getModifiers())) {
_propFrom(props, f.getName()).withField(f);
} else if (isRecord) {
// 21-Oct-2024, tatu: [jackson-jr#167] Need to retain ordering of Record
// properties. One way is to pre-create properties like so.
_propFrom(props, f.getName());
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package jr.failing;
package jr;

import com.fasterxml.jackson.jr.ob.JSON;

Expand Down
6 changes: 6 additions & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,9 @@ Tomasz Gawęda (@TomaszGaweda)

* Contributed #162: Add support for deserializing Java Records
(2.18.0)

Giovanni van der Schelde (@Giovds)

* Reported, suggested a fix for #167: Deserialization of record fails
on constructor parameter ordering
(2.18.1)
5 changes: 5 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ Modules:

-

2.18.1 (not yet released)

#167: Deserialization of record fails on constructor parameter ordering
(reported, fix suggested by Giovanni V-d-S)

2.18.0 (26-Sep-2024)

#162: Add support for deserializing Java Records
Expand Down

0 comments on commit 6429d03

Please sign in to comment.