0

We're using Payara 4 which uses Eclipselink Moxy as the default JSON to/from object mapper. We're now looking into switching to Jackson which is more suitable and easy to work with when it comes to JSON.

There is a known issue with Moxy where when it serializing a Map, the JSON will look like this:

"productsPerCost":{"entry":[{"key":"PS4","value":999}, {"key":"TV","value":1233}]}

And Jackson cannot deserialize this, and so it'll fail, because Jackson expect the Map's JSON representation to be:

"productsPerCost": {
        "PS4": 999,
        "TV": 1233
    },

jackson with jaxb

Let's say we'll switch our application to work with Jackson. If we'll call to some external system that is working with Moxy, we'll get this weird JSON from them and fail.

How to handle this?

YevgenyL
  • 281
  • 3
  • 20
  • If you would like to safe time, upgrade to Payara 5 now, so you can use JSON-B, or start using JSON-B with Payara 4. We had custom GSON adapters with Payara 4 which made it really hard to upgrade to 5. If I would have known the amount of time I had to spend on migrating to JSON-B, I would never have chosen to write those GSON adapters. – Jasper de Vries Jun 11 '20 at 15:10
  • Just telling you that it might take you a lot more work later. Been there. – Jasper de Vries Jun 11 '20 at 15:39
  • It is not my decision, but right now we're not switching yet to Payara 5. Also, as I understand, JSONB standard is available in JEE8, so I cannot use it in Payara 4 (JEE 7). Bit even when we'll move to Payara 5 snd JSONB how will be solve the above issue? Our application may make a external call to some application on Payara 4 that works with Moxy and creates those weird json represantations. – YevgenyL Jun 11 '20 at 15:41
  • Yes, thanks, I also don't want to make any drastic changes if we're going to move soon to Payara 5, but if it is not soon, then we need to figure out the above issue – YevgenyL Jun 11 '20 at 15:44
  • @JasperdeVries I thought about another issue, when we move to Payara 5 and use JSONB, we may still have the above issue, because the external systems we call may still use Moxy and deserialize Map in their weird way. – YevgenyL Jun 16 '20 at 11:17

0 Answers0