FISCO-BCOS / FISCO-BCOS/web3sdk
ResultEntity传入数组(DynamicBytes或BytesX)时,序列化会出现空字符串
- Dominant language
- Java
- Stars
- 122
- Forks
- 81
- PR merge metrics
- No merged PRs in 30d
Description
ResultEntity中,若传入数组,那么序列化ResultEntity会出现空字符串。
## 测试代码
```
@Test
public void any() throws Exception{
DynamicBytes db = new DynamicBytes(new byte[]{1,2,3});
ResultEntity resultEntity = new ResultEntity("aa","bytes",db );
System.out.println(JsonUtils.toJson(resultEntity));
Bytes3 bytes32 = new Bytes3(new byte[]{1,2,3});
resultEntity = new ResultEntity("aa","bytes32",bytes32 );
System.out.println(JsonUtils.toJson(resultEntity));
}
```
## 当前结果:
```
{"name":"aa","type":"bytes","data":""}
{"name":"aa","type":"bytes32","data":""}
```
## 期望结果
```
{"name":"aa","type":"bytes","data":[Hex或Base64编码的二进制]}
{"name":"aa","type":"bytes32","data":"[Hex或Base64编码的二进制]"}
```
## 原因分析
ResultEntity在构造函数里传入DynamicBytes或定长Bytes时,会将字节数组通过UTF8转码为字符串,这一步将产生不可读的字符串。

Contributor guide
Research direction
Start with the ResultEntity constructor and the JsonUtils.toJson calls shown in the issue, focusing on DynamicBytes and Bytes3 inputs. Reproduce the test case, inspect where the byte arrays become strings, and verify that serialization produces non-empty, consistently encoded data for both dynamic and fixed-length bytes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100