[WIP] Allow replacing json-smart with another json implementation.

Declined
#50 · Created  · Last updated

Declined pull request

JSON Smart shaded in v9.0.

Closed by: ·2020-12-28

Description

https://bitbucket.org/connect2id/nimbus-jose-jwt/issues/239/switch-to-other-json-library

Would love to get feedback on this approach. The goal is to get json-smart out of the public api so that a different json parsing lib can be used. While this is a breaking change, some care has been taken to not break clients too much.

The key idea is for everything to work with plain maps and lists instead of JSONObject and JSONArray. Pretty much any json lib can work with this. Since json-smart’s JSONObject and JSONArray extends Map and List respectively, this can be achieved in a (mostly) backwards-compatible way.

There is a ‘base’ json module which holds a JSONParser interface. There are then two modules which implement that interface using json-smart and jackson. Note: the choice of jackson was arbitrary to help test splitting things out, I’m in no-way advocating that that should be the new implementation. Each of those modules define a JSONParserProvder class to obtain an instance of a JSONParser. The nimbus module uses this to call into the implementation-defined parser.

Migration: For methods that used to take JSONObject, they now take Map. Client code should continue to compile, though it would be advised to move off of json-smart’s JSONObject to plain maps. For methods that return JSONObjects, they now return a Map. Client code can cast these to JSONObject to continue works as before but again, would be advised to migrate to working with maps.

0 attachments

0 comments

Loading commits...