Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the need to use deprecated com.mongodb.util.JSON #432

Open
ghost opened this issue Jan 30, 2020 · 0 comments
Open

Remove the need to use deprecated com.mongodb.util.JSON #432

ghost opened this issue Jan 30, 2020 · 0 comments
Labels
code improvements Improvements to make the code base more readable and manageable.

Comments

@ghost
Copy link

ghost commented Jan 30, 2020

Description

Replace the use of the deprecated com.mongodb.util.JSON where it is using JSON.serialize(document). This can be done by doing "document.toJson()". Although this will not serialize the MongoDB document and not remove MongoDB special characters. How to do that must be investigated.

Currently MongoDBHandler returns the found subscriptions etc as JSON formatted strings, this could be returned already converted to JSON to avoid problems changed down into the code. This could be done my implementing a new Class for example named MongoDBResultToJsonConverter or similar. This converter will be responsible to convert the findings in MongoDB to correct JSON.

Motivation

com.mongodb.util.JSON is deprecated and will be removed in future. Returning a JSON formatted string forces other classes to handle the responsibility of parsing a string to JSON and any faults or changes in the JSON format will inflict problems in many different parts of the code.

Exemplification

Remove usage of com.mongodb.util.JSON.
Use document.toJson()
Validate and convert this JSON to a JSON structure used within Eiffel Intelligence using a converter class.
Change all request for subscriptions or other data from MongoDB to receive a JSON (array or object) file and not a string that the called must convert.

Benefits

EI will not stop working when the deprecated com.mongodb.util.JSON class is removed.
EI will have less risks of future bugs when converting from string formatted JSON to JSON.

Possible Drawbacks

Internal data should not really be transferred among classes as JSON but an internal object for example a Subscription.class. But that implementation could be done later once all string formatted json data is removed.,

@e-pettersson-ericsson e-pettersson-ericsson added the code improvements Improvements to make the code base more readable and manageable. label Jan 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code improvements Improvements to make the code base more readable and manageable.
Projects
None yet
Development

No branches or pull requests

1 participant