Uploaded image for project: 'mUzima'
  1. mUzima
  2. MUZIMA-254

org.openmrs.module.muzimaregistration.utils.JsonUtils cannot parse and return JSON sub-objects in JSON format

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Done
    • Labels:

      Description

      This issue was observed by Shwetha Thammaiah as follows:

      I have been exploring the JsonUtil class and the way it is implemented and used. From my understanding the design approach is that :

      1. We get the form-data in a Json format

      2. We extract the necessary Json object (like observation etc) out of the whole form and use this to create a Pojo/DTO to store the object. We do this using the readAsObject method.

      3. We pass this extracted object as a string and pass it to the readAsString method to extract specific fields from the whole Json object.

      There are a few key issues with this. Firstly the current code seems to rely heavily on the fact the return json Object is of type JSONObject. However the latest version of JsonPath returns a JSONArray when we invoke read.

      Also the readAsString does not work because the JsonObject.toString() converts the object to a non conformant Json String and the JsonPath.read does not find the path and throws an exception and dies.

      I feel that the code probably was fine with an older version of JSonPath, and a newer version may have changed something to return a JSONArray instead of JSONObject.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                msavai Simon Savai (Inactive)
                Reporter:
                msavai Simon Savai (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: