mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
改进TemporalAccessorSerializer支持dayOfMonth和month枚举名
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package cn.hutool.json;
|
||||
|
||||
import cn.hutool.core.io.resource.ResourceUtil;
|
||||
import cn.hutool.core.lang.TypeReference;
|
||||
import lombok.Data;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class IssueI82AM8Test {
|
||||
|
||||
@Test
|
||||
public void toBeanTest() {
|
||||
final String json = ResourceUtil.readUtf8Str("issueI82AM8.json");
|
||||
|
||||
Map<String, MedicalCenter.MedicalCenterLocalized> bean1 =
|
||||
JSONUtil.toBean(json, new TypeReference<Map<String, MedicalCenter.MedicalCenterLocalized>>() {
|
||||
}, false);
|
||||
|
||||
bean1.forEach((k, v) -> Assert.assertNotNull(v.getTestimonials()));
|
||||
}
|
||||
|
||||
// 对象
|
||||
@Data
|
||||
public static class MedicalCenter {
|
||||
|
||||
private Map<String, MedicalCenterLocalized> medicalCenterLocalized;
|
||||
|
||||
@Data
|
||||
public static class MedicalCenterLocalized {
|
||||
|
||||
private List<Testimonial> testimonials;
|
||||
|
||||
@Data
|
||||
public static class Testimonial {
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
46
hutool-json/src/test/resources/issueI82AM8.json
Normal file
46
hutool-json/src/test/resources/issueI82AM8.json
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"en": {
|
||||
"testimonials": [
|
||||
{
|
||||
"createTime": {
|
||||
"dayOfYear": 261,
|
||||
"dayOfWeek": "MONDAY",
|
||||
"year": 2023,
|
||||
"month": "SEPTEMBER",
|
||||
"nano": 0,
|
||||
"monthValue": 9,
|
||||
"dayOfMonth": 18,
|
||||
"hour": 15,
|
||||
"minute": 18,
|
||||
"second": 0,
|
||||
"chronology": {
|
||||
"id": "ISO",
|
||||
"calendarType": "iso8601"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"zh": {
|
||||
"testimonials": [
|
||||
{
|
||||
"createTime": {
|
||||
"dayOfYear": 261,
|
||||
"dayOfWeek": "MONDAY",
|
||||
"year": 2023,
|
||||
"month": "SEPTEMBER",
|
||||
"nano": 0,
|
||||
"monthValue": 9,
|
||||
"dayOfMonth": 18,
|
||||
"hour": 15,
|
||||
"minute": 18,
|
||||
"second": 0,
|
||||
"chronology": {
|
||||
"id": "ISO",
|
||||
"calendarType": "iso8601"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user