-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deserialize Integer[] support input single integer, for issue #2593
- Loading branch information
Showing
3 changed files
with
50 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
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
38 changes: 38 additions & 0 deletions
38
core/src/test/java/com/alibaba/fastjson2/issues_2500/Issue2593.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,38 @@ | ||
package com.alibaba.fastjson2.issues_2500; | ||
|
||
import com.alibaba.fastjson2.JSON; | ||
import lombok.Data; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class Issue2593 { | ||
@Test | ||
public void test() { | ||
String str = "{\"test\":[{\"demo\": 1}]}"; | ||
Bean bean = JSON.parseObject(str, Bean.class); | ||
List<Item> items = bean.getTest(); | ||
assertEquals(1, items.size()); | ||
assertEquals(1, items.get(0).demo.length); | ||
assertEquals(1, items.get(0).demo[0]); | ||
} | ||
|
||
@Data | ||
static class Bean { | ||
List<Item> test; | ||
} | ||
|
||
@Data | ||
static class Item { | ||
private Integer[] demo; | ||
} | ||
|
||
@Test | ||
public void test1() { | ||
Long[] longs = JSON.parseObject("123", Long[].class); | ||
assertEquals(1, longs.length); | ||
assertEquals(123L, longs[0]); | ||
} | ||
} |
9f87113
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
请问fastjson2中,JSON.toJSONString怎么时间格式转?