File tree 4 files changed +28
-4
lines changed
main/java/org/example/customer/properties
test/java/org/example/customer/properties
jsonb/src/main/java/io/avaje/jsonb/core
4 files changed +28
-4
lines changed Original file line number Diff line number Diff line change
1
+ package org .example .customer .properties ;
2
+
3
+ import java .util .Properties ;
4
+
5
+ public class MyProperties extends Properties {}
Original file line number Diff line number Diff line change
1
+ package org .example .customer .properties ;
2
+
3
+ import io .avaje .jsonb .Json ;
4
+
5
+ import java .util .Properties ;
6
+
7
+ @ Json
8
+ public record PropsSub (MyProperties props ) {}
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ class PropsTest {
13
13
14
14
Jsonb jsonb = Jsonb .builder ().build ();
15
15
JsonType <Props > jsonType = jsonb .type (Props .class );
16
+ JsonType <PropsSub > jsonTypeSub = jsonb .type (PropsSub .class );
16
17
17
18
@ Test
18
19
void toJson_fromJson () {
@@ -27,4 +28,17 @@ void toJson_fromJson() {
27
28
28
29
assertThat (fromJson .props ()).containsEntry ("hi" , "hey" );
29
30
}
31
+
32
+ @ Test
33
+ void toJson_fromJson_subclass () {
34
+ MyProperties properties = new MyProperties ();
35
+
36
+ properties .setProperty ("hi" , "hey" );
37
+ PropsSub props = new PropsSub (properties );
38
+
39
+ String asJson = jsonTypeSub .toJson (props );
40
+ PropsSub fromJson = jsonTypeSub .fromJson (asJson );
41
+
42
+ assertThat (fromJson .props ()).containsEntry ("hi" , "hey" );
43
+ }
30
44
}
Original file line number Diff line number Diff line change 6
6
import io .avaje .jsonb .Jsonb ;
7
7
8
8
import java .lang .reflect .Type ;
9
- import java .util .Collection ;
10
- import java .util .List ;
11
- import java .util .Map ;
12
- import java .util .Set ;
9
+ import java .util .*;
13
10
14
11
final class CoreAdapters {
15
12
You can’t perform that action at this time.
0 commit comments