Code Monkey home page Code Monkey logo

Comments (8)

okohub avatar okohub commented on June 5, 2024

I think another point that can be arguable is using Jackson library instead of json-simple in that optimization process.

from pushy.

jchambers avatar jchambers commented on June 5, 2024

@okohub Can you elaborate? Why would that help?

from pushy.

okohub avatar okohub commented on June 5, 2024

ApnsBuilder is complicated. There are lots of things in a one "builder" class. Creating a JSON from builder result is also complicated i think. First of all, using a better library for JSON serializing and dividing core part to POJOs will help developers to improve pushy. Jackson is very powerful at POJOs. You don't have to check attribute is existing or not for serializing, for example.

from pushy.

jchambers avatar jchambers commented on June 5, 2024

You don't have to check attribute is existing or not for serializing, for example.

The APNs payload is a tricky beast. In some cases, these things are all interpreted differently by the receiving device:

  1. An attribute is present and has a non-null value
  2. An attribute is present and its value is null
  3. An attribute is not present

Jackson (or other libraries) that work by serializing POJOs deprive us of the expressive flexibility we need to reach all of those cases (i.e. there isn't a good way to differentiate between "present and null" and "not present").

from pushy.

ipeisong avatar ipeisong commented on June 5, 2024

Just an idea that when builder is called maybe the length+key length shall be calculated on the spot.
For example, builder.badge(10) increase length by 5(badge) + 1":" + 2(10). And consider the {} together, when build() is called the length shall be evaluated immediately, cause the key and symbols is predefined.

from pushy.

lpandzic avatar lpandzic commented on June 5, 2024

I've been looking through changelogs while updating our dependency and seen this:

Jackson (or other libraries) that work by serializing POJOs deprive us of the expressive flexibility we need to reach all of those cases (i.e. there isn't a good way to differentiate between "present and null" and "not present").

Jackson is not limited to pojo processing mode: there are other modes, such as Tree Model. Take a look at the 'Constructing Tree Model instances from Scratch' section.

from pushy.

jchambers avatar jchambers commented on June 5, 2024

FWIW, we switched to Gson a while ago.

from pushy.

lpandzic avatar lpandzic commented on June 5, 2024

Yeah, sorry, totally didn't see the date of that comment.

from pushy.

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.