-
Notifications
You must be signed in to change notification settings - Fork 496
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix jackson annotation JsonUnwrapped compatible, for issue #2846
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
core/src/test/java/com/alibaba/fastjson2/issues_2800/Issue2846.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.alibaba.fastjson2.issues_2800; | ||
|
||
import com.alibaba.fastjson2.JSON; | ||
import com.fasterxml.jackson.annotation.JsonUnwrapped; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class Issue2846 { | ||
@Test | ||
public void testFastJson() throws Exception { | ||
CombineView combineView = new CombineView(); | ||
String jacksonResult = new ObjectMapper().writeValueAsString(combineView); | ||
String fastjsonResult = JSON.toJSONString(new CombineView()); | ||
assertEquals(jacksonResult, fastjsonResult); | ||
} | ||
|
||
static class CombineView { | ||
@JsonUnwrapped | ||
public View1 author() { | ||
return new View1(); | ||
} | ||
} | ||
|
||
static class View1 { | ||
public String getAuthorName() { | ||
return "name"; | ||
} | ||
} | ||
} |