Did you know?  Oracle Mobile:  JSONBeanSerializationHelper Does Not Respect Case!

Did you know? Oracle Mobile: JSONBeanSerializationHelper Does Not Respect Case!

shutterstock_273386390Oracle Mobile is a framework provided by Oracle that enables developers to build cross-platform mobile applications.  At AST, a passionate set of developers are using Oracle Mobile to build mobile applications that will be used as an extension for Oracle Cloud Products.  During our development life-cycle, we discovered a fundamental issue with the Oracle Mobile framework, particularly with the JSONBeanSerializationHelper class.

The role of the JSONBeanSerializationHelper class within the Oracle Mobile framework is to convert JAVA objects to JSON strings.  A JSON string is an industry standard accepted for data representation; it consists of name: value pairs.  According to the JSON Specification, a JSON String is always case-sensitive.  When the JSONBeanSerializationHelper converts a JAVA object into name: value pairs, it doesn’t respect the variable case in the JAVA object.  All variables are converted to names in JSON strings in lowercase.

We took this up with Oracle and have an Enhancement Request (ER) logged.  We will update this post once the ER has been resolved.

Described below is a use case and how this impacts the mobile application integration with Oracle Service Cloud.  However, you could face the same issue when integrating with other Oracle Cloud Products:

Use Case

Consider a use case in which you have a mobile application built using Oracle Mobile.  The application has a feature that allows you to create an incident in Oracle Service Cloud.

Issue Details

  • Consider an Incident bean defined as:

  • An incident object will be instantiated and initialized when the user inputs the required values from the mobile interface.
  • The incident object is then converted to JSON using oracle.adfmf.framework.api.JSONBeanSerializationHelper

  • Converted jsonObject:

  • The JSON generated will not be accepted by the create incident API because:
    1. It contains “null” names: value pairs for variables that did not hold any values
    2. It contains a “type” name: value pair for variable with custom data types
    3. It contains “propertyChangeSupport” names: value pairs as the beans had a property change attribute defined. This is not expected by the create incident REST-API
    4. The JSON did not respect the case of the JAVA variables defined in the Incident bean when generating corresponding name: value pairs.
      1. For example: Consider the attribute “transit” in the JSON – the JAVA variable was defined as “Transit”. The create incident REST-API also expects the name to be “Transit”.

Workaround

  • Option 1: Create your own implementation of the JSON serialization class. 
  • Option 2: Create a method to format your JSON as a break-fix.
    • Call custom method removeNullsAndTypeFromJSON post-JSON conversion

  • removeNullsAndTypeFromJSON” method implementation:

Reference

Tagged with: , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*