-
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.
improved LocalTime parse support, fix issue #591
- Loading branch information
Showing
9 changed files
with
296 additions
and
9 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
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
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
42 changes: 42 additions & 0 deletions
42
core/src/test/java/com/alibaba/fastjson2/issues/Issue591.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,42 @@ | ||
package com.alibaba.fastjson2.issues; | ||
|
||
import com.alibaba.fastjson2.JSONObject; | ||
import com.alibaba.fastjson2.annotation.JSONField; | ||
import lombok.Data; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.time.LocalTime; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
public class Issue591 { | ||
@Test | ||
void test2() { | ||
String testStr = "{\"time\": \"09:00\", \"nest\": {\"time\": \"09:00\"}, \"nests\": [{\"time\": \"09:00\"}]}"; | ||
|
||
TestAA aa = JSONObject.parseObject(testStr, TestAA.class); | ||
assertNotNull(aa); | ||
assertNotNull(aa.time); | ||
assertNotNull(aa.nest.time); | ||
} | ||
|
||
@Data | ||
public class TestAA { | ||
private LocalTime time; | ||
private TestBB nest; | ||
// private List<TestBB> nests; | ||
} | ||
|
||
public class TestBB { | ||
@JSONField(name = "time", format = "HH:mm") | ||
private LocalTime time; | ||
|
||
public LocalTime getTime() { | ||
return time; | ||
} | ||
|
||
public void setTime(LocalTime time) { | ||
this.time = time; | ||
} | ||
} | ||
} |