Skip to content

JSON reviver doesn't deserialize nodes correctly #1077

@dqnykamp

Description

@dqnykamp

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions