Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Caused by: com.alibaba.fastjson2.JSONException: illegal fieldName input6, offset 69, character 6, line 4, column 26, fastjson-version 2.0.44 #2143

Closed
etertal opened this issue Dec 30, 2023 · 4 comments

Comments

@etertal
Copy link

etertal commented Dec 30, 2023

{
    "podConfigPackageList": [
        {
            "priceId": 65,
            "originalPrice": 46,
            "presentPrice": 88
        },
        {
            "priceId": 88,
            "originalPrice": 93,
            "presentPrice": 55
        }
    ]
}

反序列化报错。依赖库如下:

         <dependency>
            <groupId>com.alibaba.fastjson2</groupId>
            <artifactId>fastjson2</artifactId>
            <version>2.0.44</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.alibaba.fastjson2/fastjson2-extension-spring5 -->
        <dependency>
            <groupId>com.alibaba.fastjson2</groupId>
            <artifactId>fastjson2-extension-spring5</artifactId>
            <version>2.0.44</version>
        </dependency>

报错信息如下:

Caused by: com.alibaba.fastjson2.JSONException: illegal fieldName input6, offset 69, character 6, line 4, column 26, fastjson-version 2.0.44
{
    "podConfigPackageList": [
        {
            "priceId": 65,
            "originalPrice": 46,
            "presentPrice": 88
        },
        {
            "priceId": 88,
            "originalPrice": 93,
            "presentPrice": 55
        }
    ]
}
	at com.alibaba.fastjson2.JSONReaderUTF8.readFieldNameHashCode(JSONReaderUTF8.java:2676)
	at com.alibaba.fastjson2.reader.ORG_3_10_PodConfig.readObject(Unknown Source)
	at com.alibaba.fastjson2.reader.ORG_2_8_PodConfigPackage.readObject(Unknown Source)
	at com.alibaba.fastjson2.reader.ORG_1_9_PodConfigPackageVO.readObject(Unknown Source)
	at com.alibaba.fastjson2.JSON.parseObject(JSON.java:1486)
	at com.alibaba.fastjson2.support.spring.http.converter.FastJsonHttpMessageConverter.readType(FastJsonHttpMessageConverter.java:111)
	... 113 common frames omitted
@etertal
Copy link
Author

etertal commented Dec 30, 2023

后面我用字符串接收转换后,测试完成。
我又用list测试了一次,又没问题了。
很奇怪,不知道什么问题。

@CodePlayer
Copy link
Contributor

你要把对应的 Java 实体类 也贴出来,光给一个 JSON 字符串,很难定位问题所在。
你不一定要给项目中实际用到的,只要给一个能够复现该问题的 Demo 代码即可。

@etertal
Copy link
Author

etertal commented Jan 5, 2024

非常抱歉,定位到问题了,使用了lombok插件,对其中的一个字段set方法做了自定义,导致解析异常。
库没有问题,非常抱歉

@yanxutao89
Copy link
Collaborator

非常抱歉,定位到问题了,使用了lombok插件,对其中的一个字段set方法做了自定义,导致解析异常。 库没有问题,非常抱歉

没事的,感谢反馈

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants