Skip to content

Instantly share code, notes, and snippets.

@rjattrill
Created October 30, 2012 06:33
Show Gist options
  • Save rjattrill/3978641 to your computer and use it in GitHub Desktop.
Save rjattrill/3978641 to your computer and use it in GitHub Desktop.
Convert null from JSON deserialization to NaN for Number type in Actionscript
// In Actionscript, a null result from a JSON service reponse will be converted to 0.0 default when casting to a number.
// What we really want is NaN:
var rs:Object = service.result; // Result deserialized from some JSON service
var value:Number = rs.value_num == null ? NaN : rs.value_num;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment