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.

How to deal with Infinity in serialization?

See original GitHub issue

Hi, The reviver option in JSON.parse is very helpful. But, I am not sure how to deal with Infinity. At present, I am loosing its information. Here is an example:

var a="[1,2i,1/0]";
var b=math.evaluate(a);
var c = JSON.stringify(b);
var d = JSON.parse(c,  math.json.reviver);

By the time I reach last step, the variable d is losing its Infinity value.

How can I fix this problem?

Thank you for your time.

_Originally posted by @skgadi in https://github.com/josdejong/mathjs/issues/27#issuecomment-621639696_

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
josdejongcommented, May 4, 2020

Fixed now in v6.6.5

1reaction
josdejongcommented, May 3, 2020

I created a fix in 28b7a02f01c6f4d4512c7f967ff9671e732d1220 (not yet published)

Read more comments on GitHub >

github_iconTop Results From Across the Web

System.Text.Json: Handling Infinity values - Stack Overflow
From what I can tell, this is the appropriate way to handle double "Infinity" values when using NewtonsoftJson, ...
Read more >
Infinity in JavaScript - Dmitri Pavlutin
Infinity in JavaScript is a special number bigger than any finite number. ... When serialized with JSON.stringify() , the infinite number ...
Read more >
Jackson - Bidirectional Relationships - Baeldung
First, we'll discuss the Jackson JSON infinite recursion problem. Then we'll see how to serialize entities with bidirectional relationships.
Read more >
JSON serializer will write out Inifinity but JSON.parse fails to ...
This program demonstrates the problem. TestMongoInfinity.java. public class TestMongoInfinity {. public static void test ...
Read more >
Understand Serialization and Deserialization in Java
At Board Infinity we have authors leading in their profession sharing their insights, ideas and inspiration. Here influential thinkers, creators ...
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