ENH: slightly cooler way to handle nan->NaN

This uses json.dumps to translate python to javascript.
Since json.dumps is supposed to always produce valid
javascript, this could be a useful pattern for other
issues in the future.