• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.fasterxml.jackson.databind.struct;
2 
3 import com.fasterxml.jackson.annotation.*;
4 
5 import com.fasterxml.jackson.databind.*;
6 
7 // Problem with recursive definition of unwrapping
8 public class TestUnwrappedRecursive383 extends BaseMapTest
9 {
10     // [databind#383]
11     static class RecursivePerson {
12         public String name;
13         public int age;
14         @JsonUnwrapped(prefix="child.") public RecursivePerson child;
15     }
16 
17     /*
18     /**********************************************************
19     /* Tests, serialization
20     /**********************************************************
21      */
22 
23     private final ObjectMapper MAPPER = new ObjectMapper();
24 
testRecursiveUsage()25     public void testRecursiveUsage() throws Exception
26     {
27         final String JSON = "{ 'name': 'Bob', 'age': 45, 'gender': 0, 'child.name': 'Bob jr', 'child.age': 15 }";
28         RecursivePerson p = MAPPER.readValue(aposToQuotes(JSON), RecursivePerson.class);
29         assertNotNull(p);
30         assertEquals("Bob", p.name);
31         assertNotNull(p.child);
32         assertEquals("Bob jr", p.child.name);
33     }
34 }
35