Code Monkey home page Code Monkey logo

Comments (3)

JiamingFB avatar JiamingFB commented on April 28, 2024

Hi Kilink,

We use different Gson instance for each class because the Gson parsing settings might be different for different classes. Although it is not happening right now, we want to keep the flexibility for the future.

If you've got performance hit because of this, please let us know so that we can try to find a solution.

from facebook-java-business-sdk.

kilink avatar kilink commented on April 28, 2024

It confers other benefits apart from performance. Currently I can't customize the Gson instance whatsoever (e.g., to turn on pretty printing).

The Gson instance could still be moved to APIContext, and when the need for a customized instance for a specific type arises, then you could handle it either using the current approach in that specific place, or via a factory method on the context (maybe by exposing the GsonBuilder?).

As I mentioned in another issue, I will open a PR for this if you guys agree that it's a good idea.

from facebook-java-business-sdk.

kilink avatar kilink commented on April 28, 2024

Additionally, I think any class/type-specific behavior can be achieved with type adapters or custom serializers/deserializers, while still maintaining the single Gson instance.

from facebook-java-business-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.