Answer the question
In order to leave comments, you need to log in
How to parse a string into an object (AST)?
Hello.
I need to parse a line like this
const str="SALARY('@JohnSmith') = {USER.workingHours} * {USER.hourlyRate}";
const result = [
{type: 'function', name: 'SALARY', params: ['@JohnSmith']},
{type: 'entity', name: 'USER', fields: ['workingHours']},
{type: 'mathOperation', operator: 'mutliply'},
{type: 'entity', name: 'USER', fields: ['hourlyRate']}
]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question