-
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.
Browse files
Browse the repository at this point in the history
* fix ignore cast exception, for issue #2665
- Loading branch information
1 parent
82f1cfc
commit 8ac4553
Showing
3 changed files
with
65 additions
and
17 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
61 changes: 61 additions & 0 deletions
61
fastjson1-compatible/src/test/java/com/alibaba/fastjson/issues_compatible/Issue2665.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,61 @@ | ||
package com.alibaba.fastjson.issues_compatible; | ||
|
||
import com.alibaba.fastjson.JSONArray; | ||
import com.alibaba.fastjson2.JSON; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class Issue2665 { | ||
@Test | ||
public void test() { | ||
String json = "[\r\n" | ||
+ " {\r\n" | ||
+ " \"date\": \"2024-06-10\",\r\n" | ||
+ " \"slots\": [\r\n" | ||
+ " {\r\n" | ||
+ " \"createDate\": \"2024-06-10T11:54:58.240+01:00\",\r\n" | ||
+ " \"expireDate\": \"2024-06-10T11:59:58.240+01:00\",\r\n" | ||
+ " \"id\": 1176592662,\r\n" | ||
+ " \"intervention\": {\r\n" | ||
+ " \"code\": \"FS\",\r\n" | ||
+ " \"name\": \"FA Simple\"\r\n" | ||
+ " },\r\n" | ||
+ " \"timeslot\": {\r\n" | ||
+ " \"code\": \"AM\",\r\n" | ||
+ " \"end\": \"13:00\",\r\n" | ||
+ " \"name\": \"Morning\",\r\n" | ||
+ " \"start\": \"08:00\"\r\n" | ||
+ " }\r\n" | ||
+ " }\r\n" | ||
+ " ]\r\n" | ||
+ " },\r\n" | ||
+ " {\r\n" | ||
+ " \"date\": \"2024-06-10\",\r\n" | ||
+ " \"slots\": [\r\n" | ||
+ " {\r\n" | ||
+ " \"createDate\": \"2024-05-22T11:54:58.240+01:00\",\r\n" | ||
+ " \"expireDate\": \"2024-05-22T11:59:58.240+01:00\",\r\n" | ||
+ " \"id\": 1176592671,\r\n" | ||
+ " \"intervention\": {\r\n" | ||
+ " \"code\": \"FS\",\r\n" | ||
+ " \"name\": \"FA Simple\"\r\n" | ||
+ " },\r\n" | ||
+ " \"timeslot\": {\r\n" | ||
+ " \"code\": \"PM\",\r\n" | ||
+ " \"end\": \"18:00\",\r\n" | ||
+ " \"name\": \"Afternoon\",\r\n" | ||
+ " \"start\": \"13:00\"\r\n" | ||
+ " }\r\n" | ||
+ " }\r\n" | ||
+ " ]\r\n" | ||
+ " }\r\n" | ||
+ "]"; | ||
|
||
JSONArray jsonArr = JSONArray.parseArray(json); | ||
List list = jsonArr.toJavaObject(List.class); | ||
assertEquals(JSON.toJSONString(jsonArr), JSON.toJSONString(list)); | ||
} | ||
} |