alibaba / alibaba/fastjson2

[BUG]特定环境下put数字导致乱码

Open
#2,051 4 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
4.4k
Forks
613
Avg merge
1d 22h
Merged PRs (30d)
6

Description

### 问题描述
*简要描述您碰到的问题。*

### 环境信息
*请填写以下信息:*

- OS信息: [e.g.:Linux http-in-cloud 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:29 UTC 2023 s390x s390x s390x GNU/Linux]
- JDK信息: [e.g.:Openjdk 17]
- 版本信息:[e.g.:Fastjson2 2.0.42]

### 重现步骤
*如何操作可以重现该问题:*

去ibm的https://linuxone.cloud.marist.edu/#/login 申请服务器
写一个使用fastjson2的jar(换了好几个版本,基本都是乱码)
带依赖打包jar
使用java -jar 打包的jar名称

如图所示部分数字出现了乱码,且在win下运行时完全正常
在换用org.json时输出完全正常
"""



src/main/resources
true



Httpserver


maven-compiler-plugin
3.11.0

17
17



org.apache.maven.plugins
maven-assembly-plugin
3.6.0


src/main/assembly/assembly.xml



org.example.Main





make-assembly
package


single





org.apache.maven.plugins
maven-resources-plugin
3.3.1


copy-resources
validate

copy-resources


${basedir}/target/classes


src/main/resources
true








"""
```java
//可在此输入示例代码
JSONObject json = JSONObject.parseObject("{}");
json.put("text2",1);
json.put("text",0);
System.out.printf(json +"\n");
```

### 期待的正确结果
*对您期望发生的结果进行清晰简洁的描述。*
正确的输出数字

### 相关日志输出
*请复制并粘贴任何相关的日志输出。*

#### 附加信息
*如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。*

Contributor guide

Open the contributing guide

Research direction

Reproduce the report on the IBM Linux s390x environment with JDK 17, using the JSONObject.parseObject, put, and System.out.printf example in the issue. Compare the numeric output with Windows and org.json, then trace the relevant Fastjson2 serialization path; done means the example prints the expected numbers on the affected environment.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.