Remove the need to use deprecated com.mongodb.util.JSON
Opened this issue · 0 comments
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.,