0

I have for example expression like:

const expression = 'delta(var(123), 20)'

Then I use math.parse on that to validate it with mathjs. Output of parsing with mathjs:

    "mathjs": "FunctionNode",
    "fn": {
        "mathjs": "SymbolNode",
        "name": "delta"
    },
    "args": [
        {
            "mathjs": "FunctionNode",
            "fn": {
                "mathjs": "SymbolNode",
                "name": "var"
            },
            "args": [
                {
                    "mathjs": "ConstantNode",
                    "value": 123
                }
            ]
        },
        {
            "mathjs": "ConstantNode",
            "value": 20
        }
    ]
}

Then I have to use stringify because my backend takes the string instead MathNode type and is making some calculation there.

How to convert back to simple expression like delta(var(123), 20) from string: '{"mathjs": "FunctionNode", "fn": {"mathjs": "SymbolNode", "name": "delta"}, "args": [{"mathjs": "FunctionNode", "fn": {"mathjs": "SymbolNode", "name": "var"}, "args": [{"mathjs": "ConstantNode", "value": "123"}]}, {"mathjs": "ConstantNode", "value": 20}]}'

Iv tried many parsing methods, creation of the new FunctionNode and always ended up failing. Can't get any information about parsing back from the mathjs docs.

YOZA
  • 13
  • 3

0 Answers0