mendix / RestServices

REST service module for Mendix. Supports consuming and publishing REST based services and real-time data synchronization. Supports JSON, form-encoded, multipart and binary data transport.
Apache License 2.0
31 stars 46 forks source link

Added support for null values on integers, floats and long values #57

Closed simo101 closed 9 years ago

simo101 commented 9 years ago

Added support for null values on integers, floats and long values

mweststrate commented 9 years ago

Hi Simon,

Thanks for the pull request! The pull request seems fine. One question, is there a specific reason that you don't want to throw an error but rather return null? Mendix indeed allows 'null' values for most primitives, but needing to deal with this in microflows is usually cumbersome, so would just throwing and exception work as well?

What was your use case for this? Was there a Mendix rest service that delivered null values for primitives (in that case we might also skip the attribute) or are you consuming an external services that actually returns null values where you expected a number?

simo101 commented 9 years ago

So I was working on integrating with Uber developers API. In the API if there is no price then it will return null. https://developer.uber.com/v1/endpoints/#price-estimates. When i was trying to call this request it would throw an error because it believed it wasn't the right type. So yes this service will return a null for a float when the low or high estimate price doesn't exist. As Mendix supports nulls I thought it would just be easiest to change this part of the code.

mweststrate commented 9 years ago

Fun, didn't expect such a case in the wild :). But well it is valid json, and valid in Mendix as well, so the solution seems fine. Accepted :) Thanks for contributing!