-
Notifications
You must be signed in to change notification settings - Fork 495
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix readZonedDateTime support read null for issue #1861
- Loading branch information
1 parent
0796a9b
commit 217dc8b
Showing
4 changed files
with
92 additions
and
14 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
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
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
59 changes: 59 additions & 0 deletions
59
core/src/test/java/com/alibaba/fastjson2/issues_1800/Issue1861.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,59 @@ | ||
package com.alibaba.fastjson2.issues_1800; | ||
|
||
import com.alibaba.fastjson2.JSON; | ||
import com.alibaba.fastjson2.JSONWriter; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import javax.validation.Valid; | ||
import java.time.OffsetDateTime; | ||
import java.util.Map; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public class Issue1861 { | ||
@Test | ||
public void test() { | ||
String json = "{\"myData1\":{\"myData2\":{\"key\":{\"startTime\":null}}}}"; | ||
MyData data = JSON.parseObject(json, MyData.class); | ||
assertEquals(json, JSON.toJSONString(data, JSONWriter.Feature.WriteNulls)); | ||
} | ||
|
||
public class MyData { | ||
private MyData1 myData1; | ||
|
||
public MyData1 getMyData1() { | ||
return myData1; | ||
} | ||
|
||
public void setMyData1(MyData1 myData1) { | ||
this.myData1 = myData1; | ||
} | ||
} | ||
|
||
public class MyData1 { | ||
@JsonProperty("myData2") | ||
private @Valid Map<String, MyData2> myData2 = null; | ||
|
||
public Map<String, MyData2> getMyData2() { | ||
return myData2; | ||
} | ||
|
||
public void setMyData2(Map<String, MyData2> myData2) { | ||
this.myData2 = myData2; | ||
} | ||
} | ||
|
||
public class MyData2 { | ||
@JsonProperty("startTime") | ||
private OffsetDateTime startTime; | ||
|
||
public OffsetDateTime getStartTime() { | ||
return startTime; | ||
} | ||
|
||
public void setStartTime(OffsetDateTime startTime) { | ||
this.startTime = startTime; | ||
} | ||
} | ||
} |