Skip to content
New issue

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

[BUG] JSON.parseObject throws TODO exception #2593

Closed
Cooper-Zhong opened this issue May 17, 2024 · 3 comments
Closed

[BUG] JSON.parseObject throws TODO exception #2593

Cooper-Zhong opened this issue May 17, 2024 · 3 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@Cooper-Zhong
Copy link

问题描述

JSON.parseObject解析以下代码时,fastjson 1.2.83抛出对应的错误信息,而fastjson2 抛出JSONException: TODO。其中{"demo": 1}为illegal 字段,正确格式如:{"demo": [1]},可以完善一下exception信息。

环境信息

  • OS信息: [MacOS 12.7.4 M1 Pro 16 GB]
  • JDK信息: [Openjdk 17.0.6]
  • 版本信息:[Fastjson2 2.0.50]

重现步骤

import com.alibaba.fastjson2.JSON;
import lombok.Data;
import org.junit.jupiter.api.Test;

import java.util.List;

public class MutatedIssue464_432 {
    @Test
    public void test0() {
        String str = "{\"test\":[{\"demo\": 1}]}";
        TestParam param = JSON.parseObject(str, TestParam.class);
        List<Demo> testList = param.getTest();
    }

    @Data
    static class TestParam {
        List<Demo> test;
    }

    @Data
    static class Demo {
        private Integer[] demo;
    }
}

相关日志输出

// fastjson 1.2.83
com.alibaba.fastjson.JSONException: field demo expect '[', but int, pos 19, line 1, column 20{"test":[{"demo": 1}]}

// fastjson 2.0.50
com.alibaba.fastjson2.JSONException: TODO, offset 19, character 1, line 1, column 19, fastjson-version 2.0.51 {"test":[{"demo": 1}]}
at com.alibaba.fastjson2.reader.ObjectReaderImplInt32Array.readObject(ObjectReaderImplInt32Array.java:87)
at com.alibaba.fastjson2.reader.ORG_2_1_Demo.readObject(Unknown Source)
at com.alibaba.fastjson2.reader.ORG_1_1_TestParam.readObject(Unknown Source)
at com.alibaba.fastjson2.JSON.parseObject(JSON.java:786)
at MutatedIssue464_432.test0(MutatedIssue464_432.java:14)

@Cooper-Zhong Cooper-Zhong added the bug Something isn't working label May 17, 2024
@wenshao wenshao added this to the 2.0.51 milestone May 17, 2024
@wenshao wenshao added the fixed label May 17, 2024
@wenshao
Copy link
Member

wenshao commented May 17, 2024

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.51-SNAPSHOT/
问题已修复,请帮忙用2.0.51-SNAPSHOT版本验证

@Cooper-Zhong
Copy link
Author

验证已修复,辛苦温少

@wenshao
Copy link
Member

wenshao commented Jun 1, 2024

https://github.com/alibaba/fastjson2/releases/tag/2.0.51
问题已修复,请用新版本

@wenshao wenshao closed this as completed Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

2 participants