GIScience / openrouteservice

🌍 The open source route planner api with plenty of features.
https://openrouteservice.org
GNU General Public License v3.0
1.43k stars 393 forks source link

Replace org.json.json-simple with Jackson annotations #1395

Open MichaelsJP opened 1 year ago

MichaelsJP commented 1 year ago

Reduce the used JSON libraries to just org.json.json/org.json.json-simple and jackson. Currently, org.json.json-simple is used to serialize certain API responses, whereas org.json.json is also used in different situations.

This should be replaced by clear POJOs with jackson annotations where possible (mostly in the API context, (de)serializing POJOs) and with a replacement of one of the JSON packages with the chosen one.

I have no clear opinion towards one of the JSON packages.

Suggested Strategy

Those libraries are mostly used in generating Geo JSON responses. Cleaning it up will require to create a couple of more Geo JSON domain classes. Geo JSON classes are currently spread over different subpackages within org.heigit.ors.api.responses.

Suggestion:

Tasks

All tasks can be tackled in individual PRs.

MichaelsJP commented 1 year ago

The api also uses GeoJSON for requests. So, it might make sense to move it one level higher or to commons, so it's available for requests and responses alike.

In general, I very much like the approach. This will also enhance the swagger documentation since it can give more detailed information when the objects are Jackson serializable and not just plain JSON objects being parsed :+1: .

As detailed, we could have a few PRs each migrating one endpoint, to not kill it with a single one.