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] Deserializing error with okhttp and fastJson2 while reading a Jackson Model class #3316

Open
mehulparmariitr opened this issue Jan 24, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@mehulparmariitr
Copy link

mehulparmariitr commented Jan 24, 2025

  • OS信息: macos 14.7.2
  • JDK信息: Zulu 8.65.0.54-SA-macos-aarch64
  • 版本信息:Fastjson 2.0.54
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?

@mehulparmariitr mehulparmariitr added the bug Something isn't working label Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant