question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Handle NaN and Infinity, set them to Null, like JSON does

See original GitHub issue
    function append(data) {
      data == null || data === NaN || data === Infinity ? appendByte(0xc0) :
      (
        data.constructor === String ? appendString :
        data.constructor === Number ? appendNumber :
        data.constructor === Boolean ? appendBoolean :
        Array.isArray(data) ? appendArray :
        data instanceof Date ? appendDate :
        appendObject
      )(data)
    }

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ygoecommented, Oct 25, 2018

Can you please specify what exactly needs to be converted to what in what function? I just tried to put NaN through the test code and got null back which seems to be what you’re asking for.

0reactions
SaulDoesCodecommented, Oct 25, 2018

Hmm, that’s interesting I’ll just remove the checks then and let DataView figure it out as you say. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JSON left out Infinity and NaN; JSON status in ECMAScript?
Any idea why JSON left out NaN and +/- Infinity? It puts Javascript in the strange situation where objects that would otherwise be...
Read more >
Handling of infinity and NaN #397 - boostorg/json - GitHub
NaN is serialized as such but then it actually throws as it's not recognized ... 1e800 is Infinity (-1e800) in JS, plus NaN...
Read more >
json.dumps() should encode float number NaN to null
Float numbers in Python can have 3 special number: nan, inf, -inf, which are encoded by json module as "NaN", "Infinity", "-Infinity".
Read more >
How to handle null, infinity, and not-a-number values
This guide will show you how to handle null, infinity, and not-a-number (NaN) values in your datasets. Not all numeric types support each...
Read more >
JSON Files - Spark 3.3.1 Documentation
Property Name Default Scope primitivesAsString false read prefersDecimal false read allowComments false read
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found