[BUG] Deserializing error with okhttp and fastJson2 while reading a Jackson Model class
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
- OS信息: macos 14.7.2
- JDK信息: Zulu 8.65.0.54-SA-macos-aarch64
- 版本信息:Fastjson 2.0.54
```java
try (Response okHttpResponse = client.httpClient.newCall(request).execute()) {
if (!okHttpResponse.isSuccessful()) {
logger.severe("Error in calling Rest API : " + okHttpResponse);
throw new IOException("Unexpected code " + okHttpResponse);
}
// Handle the response
try (ResponseBody responseBody = okHttpResponse.body()) {
if (responseBody != null) {
try (InputStream inputStream = responseBody.byteStream()) {
model = JSON.parseObject(inputStream, Model.class);
}
} else {
logger.severe("Empty response body ");
}
}
logger.exiting(model);
return model;
}
```
My `Model.class` is using Jackson annotations(jackson 2.10.0 version class) -
```
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
```
While deserializing I am getting the error -
```
not support input PD94bWwgdmVyc2lvbj0iMWRSdzVk8+, offset 5476, character }, line 1, column 5476, fastjson-version 2.0.54
```
Is fastJson2 not compatible with jackson classes, or is it not able to read `responseBody.byteStream()` from OkHttp response?
Contributor guide
Research direction
Start by reproducing the call at JSON.parseObject(inputStream, Model.class) with the OkHttp response body and the shown Model annotations. Compare the response bytes and content type with the parser's expected JSON input, then determine whether the failure comes from the stream contents or Jackson annotation handling. Done means identifying the compatibility or input problem and adding a focused regression test if the repository has a relevant test location.
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
- 35/100