Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON reviver doesn't deserialize nodes correctly #1077

Closed
dqnykamp opened this issue Apr 2, 2018 · 2 comments
Closed

JSON reviver doesn't deserialize nodes correctly #1077

dqnykamp opened this issue Apr 2, 2018 · 2 comments
Labels

Comments

@dqnykamp
Copy link

dqnykamp commented Apr 2, 2018

The JSON reviver math.json.reviver is not deserializing nodes correctly.
Example:

var x = math.parse("x/2");
var x2 = JSON.parse(JSON.stringify(x), math.json.reviver);
console.log(x.toString());  // outputs 'x / 2'
console.log(x2.toString());  // outputs [object Object]

It seems like x2 is composed of vanilla Javascript objects rather than nodes. Omitting the reviver completely achieves the same result, as demonstrated with underscore.

var x3 = JSON.parse(JSON.stringify(x));
console.log(_.isEqual(x2,x3));  // outputs true
console.log(_.isEqual(x,x2));  // outputs false
@josdejong
Copy link
Owner

josdejong commented Apr 4, 2018

Thanks for reporting, nodes are indeed not supported in serialization/deserialization. We should definitely add this. Same holds for the ResultSet class I think (result of multi line expressions like math.eval("a=1\nb=2").

EDIT: I see ResultSet already supports serialization, so it's just the nodes that we need to extend (I'm working on it).

@josdejong
Copy link
Owner

Should be fixed now in v4.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants