How to handle the new service JSON response format.

Follow

Before our January 16th Murano release, a call to a service that returned an array with one element would convert to JSON as an array (e.g., '{"measurements": [44]}'), whereas an empty array would convert to JSON as an object (e.g., '{"measurements": {}}'). Additionally, a result that contained a null value would be removed from JSON entirely, but will now be preserved. This may affect your solution if it makes calls to services like Tsdb that return lists of items. Here are some examples:

 

Now

After JSON conversion improvement

result = Service.method1()

return result

-- outputs {"measurements": {}}

result = Service.method1()

return result

-- outputs {"measurements": []}

result = Service.method2()

return result

-- outputs {}

result = Service.method2()

return result

-- outputs {"error": null}

Have more questions? Submit a request

Comments