peelonet / tempearly

Minimal scripting language / templating engine.
2 stars 0 forks source link

JSON serialization for NaN and infinite numbers. #104

Closed RauliL closed 9 years ago

RauliL commented 9 years ago

Just calling __str__ for Float class is not good enough solution to serialize numbers into JSON, as it ignores NaN and infinite numbers. According to ECMA-262 (NOTE4 on page 208), NaN and infinite numbers should serialize into JSON value null.

Solution: Add as_json method to Float class which checks for NaN/infinity.

jupelius commented 9 years ago

107 Should fix this.