File tree 2 files changed +47
-0
lines changed
yaml/src/test/java/com/fasterxml/jackson/dataformat/yaml/misc
2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ Modules:
20
20
#226 : (yaml) Quote ' y' /' Y' /' n' /' N' as names too (to avoid problems with Boolean keys)
21
21
(requested by pnepywoda@github)
22
22
#229 : (yaml) Allow configuring the way " must quote" is determined for property names, String values
23
+ #231 : Typed object with anchor throws Already had POJO for id (note: actual
24
+ fix in `jackson-annotations`)
25
+ (reported by almson@github)
23
26
- Add configurability of "YAML version generator is to follow" via "YAMLFactory.builder()"
24
27
- SnakeYAML 1.26 -> 1.27
25
28
- Add Gradle Module Metadata (https:// blog.gradle.org/alignment-with-gradle-module-metadata)
Original file line number Diff line number Diff line change
1
+ package com .fasterxml .jackson .dataformat .yaml .misc ;
2
+
3
+ import java .util .List ;
4
+
5
+ import com .fasterxml .jackson .annotation .*;
6
+
7
+ import com .fasterxml .jackson .databind .ObjectMapper ;
8
+ import com .fasterxml .jackson .dataformat .yaml .*;
9
+
10
+ public class ObjectAndTypeId231Test extends ModuleTestBase
11
+ {
12
+ static class Container {
13
+ @ JsonProperty
14
+ public List <Base > list ;
15
+ }
16
+
17
+ @ JsonTypeInfo (use = JsonTypeInfo .Id .NAME )
18
+ @ JsonSubTypes ({@ JsonSubTypes .Type (name ="Derived" , value =Derived .class )})
19
+ @ JsonIdentityInfo (generator = ObjectIdGenerators .StringIdGenerator .class )
20
+ static class Base {
21
+
22
+ }
23
+
24
+ static class Derived extends Base {
25
+ @ JsonProperty
26
+ String a ;
27
+ }
28
+
29
+ private final ObjectMapper MAPPER = newObjectMapper ();
30
+
31
+ // [dataformats-text#231]
32
+ public void testTypeAndObjectId231 () throws Exception
33
+ {
34
+ String yaml = "list:\n " +
35
+ " - !Derived &id1\n " +
36
+ " a: foo" ;
37
+ Container container = MAPPER .readValue (yaml , Container .class );
38
+ assertNotNull (container );
39
+ assertNotNull (container .list );
40
+ assertEquals (1 , container .list .size ());
41
+
42
+ System .out .println (((Derived )container .list .get (0 )).a );
43
+ }
44
+ }
You can’t perform that action at this time.
0 commit comments