Created
October 30, 2012 06:33
-
-
Save rjattrill/3978641 to your computer and use it in GitHub Desktop.
Convert null from JSON deserialization to NaN for Number type in Actionscript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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