File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed 
src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ package  com.fasterxml.jackson.module.kotlin.test.github 
2+ 
3+ import  com.fasterxml.jackson.annotation.JsonTypeInfo 
4+ import  com.fasterxml.jackson.databind.ObjectMapper 
5+ import  com.fasterxml.jackson.module.kotlin.readValue 
6+ import  com.fasterxml.jackson.module.kotlin.registerKotlinModule 
7+ import  kotlin.test.Test 
8+ import  kotlin.test.assertEquals 
9+ 
10+ @JsonTypeInfo(use =  JsonTypeInfo .Id .NAME , property =  " _type"  )
11+ private  sealed  class  BaseClass 
12+ 
13+ private  data class  ChildClass (val  text :  String ) : BaseClass()
14+ 
15+ class  GitHub844  {
16+     @Test
17+     fun  test () {
18+         val  json =  """ 
19+         { 
20+             "_type": "ChildClass", 
21+             "text": "Test" 
22+         } 
23+         """  
24+ 
25+         val  jacksonObjectMapper =  ObjectMapper ().registerKotlinModule()
26+         val  message =  jacksonObjectMapper.readValue<BaseClass >(json)
27+ 
28+         assertEquals(ChildClass (" Test"  ), message)
29+     }
30+ }
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments