We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
简要描述您碰到的问题。 原对象中包含LocalDate类型属性且不为空,但目标对象无该属性时使用JSONB对象执行反序列化报错
请填写以下信息:
如何操作可以重现该问题:
Exception in thread "main" com.alibaba.fastjson2.JSONException: name not support input : LOCAL_DATE -87 at com.alibaba.fastjson2.JSONReaderJSONB.notSupportType(JSONReaderJSONB.java:2633) at com.alibaba.fastjson2.JSONReaderJSONB.skipValue(JSONReaderJSONB.java:2594) at com.alibaba.fastjson2.reader.ObjectReaderBean.processExtra(ObjectReaderBean.java:134) at com.alibaba.fastjson2.reader.ORG_1_1_Hanbao.readJSONBObject(Unknown Source) at com.alibaba.fastjson2.JSONB.parseObject(JSONB.java:799) at com.kykj.hk.base.common.bean.Bean2Utils.clone(Bean2Utils.java:50) at com.kykj.hk.base.common.bean.Bean2Utils.deepCopyTest(Bean2Utils.java:201) at com.kykj.hk.base.common.bean.Bean2Utils.main(Bean2Utils.java:190)
6.调用代码
package com.kykj.hk.base.common.bean; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONB; import com.alibaba.fastjson2.JSONReader; import com.alibaba.fastjson2.TypeReference; import com.google.common.collect.Lists; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import lombok.experimental.UtilityClass; import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanWrapperImpl; import org.springframework.lang.Nullable; import org.springframework.util.CollectionUtils; import java.beans.PropertyDescriptor; import java.time.LocalDate; import java.util.*; import java.util.function.BiConsumer; import java.util.function.Supplier; /** * @author ChenHao * @date 2023/5/31 18:15 */ @UtilityClass public class Bean2Utils extends BeanUtils { public static <T, R> R clone(final T source, Class<R> destClass) { if (source == null) { return null; } JSONReader.Feature[] features = { JSONReader.Feature.ErrorOnNotSupportAutoType, JSONReader.Feature.IgnoreAutoTypeNotMatch }; return JSONB.parseObject(JSONB.toBytes(source), destClass,features); } public static void main(String[] args) { deepCopyTest(); } private static void deepCopyTest() { Food food = new Food(); food.setDate(LocalDate.of(2024,1,1)); food.setName("AA1"); food.setAge("18"); Hanbao hanbao = new Hanbao(); hanbao.setName("汉堡"); food.setHanbao(hanbao); Hanbao clone = clone(food, Hanbao.class); System.out.println(clone); } @Data @AllArgsConstructor @NoArgsConstructor private static class Food { private String name; private String age; private Hanbao hanbao; private LocalDate date; } @Data @AllArgsConstructor @NoArgsConstructor private static class Hanbao { private String name; // private LocalDate date1; } }
对您期望发生的结果进行清晰简洁的描述。 希望可以正确执行
请复制并粘贴任何相关的日志输出。
如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。
The text was updated successfully, but these errors were encountered:
https://github.com/alibaba/fastjson2/releases/tag/2.0.53 问题已修复,请用新版本
Sorry, something went wrong.
No branches or pull requests
问题描述
简要描述您碰到的问题。
原对象中包含LocalDate类型属性且不为空,但目标对象无该属性时使用JSONB对象执行反序列化报错
环境信息
请填写以下信息:
重现步骤
如何操作可以重现该问题:
6.调用代码
期待的正确结果
对您期望发生的结果进行清晰简洁的描述。
希望可以正确执行
相关日志输出
请复制并粘贴任何相关的日志输出。
附加信息
如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。
The text was updated successfully, but these errors were encountered: