• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.fasterxml.jackson.failing;
2 
3 import java.math.BigDecimal;
4 import java.util.List;
5 
6 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
7 
8 import com.fasterxml.jackson.databind.*;
9 
10 public class RecursiveIgnoreProperties1755Test extends BaseMapTest
11 {
12     // for [databind#1755]
13     static class JackBase1755 {
14         public String id;
15     }
16 
17     static class JackExt extends JackBase1755 {
18         public BigDecimal quantity;
19         public String ignoreMe;
20 
21         @JsonIgnoreProperties({"ignoreMe"})
22         public List<JackExt> linked;
23 
24         public List<KeyValue> metadata;
25     }
26 
27     static class KeyValue {
28         public String key;
29         public String value;
30     }
31 
32     // for [databind#1755]
33 
34     private final ObjectMapper MAPPER = newJsonMapper();
35 
testRecursiveIgnore1755()36     public void testRecursiveIgnore1755() throws Exception
37     {
38         final String JSON = aposToQuotes("{\n"
39                 +"'id': '1',\n"
40                 +"'quantity': 5,\n"
41                 +"'ignoreMe': 'yzx',\n"
42                 +"'metadata': [\n"
43                 +"           {\n"
44                 +"              'key': 'position',\n"
45                 +"              'value': '2'\n"
46                 +"          }\n"
47                 +"       ],\n"
48                 +"'linked': [\n"
49                 +"     {\n"
50                 +"         'id': '1',\n"
51                 +"         'quantity': 5,\n"
52                 +"         'ignoreMe': 'yzx',\n"
53                 +"         'metadata': [\n"
54                 +"          {\n"
55                 +"              'key': 'position',\n"
56                 +"             'value': '2'\n"
57                 +"         }\n"
58                 +"     ]\n"
59                 +"   }\n"
60                 +"  ]\n"
61                 +"}");
62         JackExt value = MAPPER.readValue(JSON, JackExt.class);
63         assertNotNull(value);
64     }
65 }
66