alibaba / alibaba/fastjson2

[BUG] fieldName not support input type STR_UTF16 123, offset 1

Open
#2,993 1 comment 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

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

JSONString: {"terminal_version":"MT5","server":"Exness-MT5Trial14","login":189193036,"client_id":"$1$E6e.eu23$ZKPS96lkiCcfSo5iILvgl.","type":"initialize","data":"{\"server\":\"Exness-MT5Trial14\",\"login\":189193036}"}

CODE: JSON.parseObject(raw, DtbMessage.class);
EXCEPTION:
com.alibaba.fastjson2.JSONException: not support input {"server":"Exness-MT5Trial14","login":189193036}, offset 206, character }, line 1, column 206, fastjson-version 2.0.53 {"terminal_version":"MT5","server":"Exness-MT5Trial14","login":189193036,"client_id":"$1$E6e.eu23$ZKPS96lkiCcfSo5iILvgl.","type":"initialize","data":"{\"server\":\"Exness-MT5Trial14\",\"login\":189193036}"}
at com.alibaba.fastjson2.JSONReader.readBinary(JSONReader.java:690)
at com.alibaba.fastjson2.reader.ObjectReaderImplInt8ValueArray.readObject(ObjectReaderImplInt8ValueArray.java:82)
at com.alibaba.fastjson2.reader.ORG_2_6_DtbMessage.readObject(Unknown Source)
at com.alibaba.fastjson2.JSON.parseObject(JSON.java:1534)

JSONString: {"terminal_version":"MT5","server":"Exness-MT5Trial14","login":189193036,"client_id":"$1$E6e.eu23$ZKPS96lkiCcfSo5iILvgl.","type":"initialize","data":"{\"server\":\"Exness-MT5Trial14\",\"login\":189193036}"}
CODE: JSONB.parseObject(raw, DtbMessage.class); raw is byte[]
EXCEPTION:
com.alibaba.fastjson2.JSONException: fieldName not support input type STR_UTF16 123, offset 1
at com.alibaba.fastjson2.JSONReaderJSONB.readFieldNameHashCodeError(JSONReaderJSONB.java:1635)
at com.alibaba.fastjson2.JSONReaderJSONB.readFieldNameHashCode(JSONReaderJSONB.java:1537)
at com.alibaba.fastjson2.reader.ORG_1_6_DtbMessage.readJSONBObject(Unknown Source)
at com.alibaba.fastjson2.JSONB.parseObject(JSONB.java:491)

![image](https://github.com/user-attachments/assets/2b046161-fcf3-41a1-9dff-80500b8b148e)

Fastjson2 2.0.53

Contributor guide

Open the contributing guide

Research direction

Reproduce the two failures with JSON.parseObject and JSONB.parseObject using the provided DtbMessage and byte[] input. Start at JSONReaderJSONB.java:1537 and 1635, then inspect the JSONB.parseObject and DtbMessage read paths; done when the provided inputs no longer reject the nested data or STR_UTF16 field name and a regression test covers the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.