Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
Escaping square brackets with node expressionparser

I am using node expressionparser in combination with jsonpath-plus library to parse json paths and read the data out of a json object based on the term returned. Here is what my parser code looks like:

export function initialiseParser(workerObject: WorkerObjectType): ExpressionParser {
  return init(formula, (term: string) => {
    if (term === '$NULL') {
      return '$NULL';
    } else if (term.startsWith('$VALUE:')) {
      const [, key] = term.split('$VALUE:');
      return getJsonData({ path: key, json: workerObject }) ?? '$NULL';
    } else {
      return '$NULL';
    }
  });
}

I am trying to parse the below expression: $VALUE:Worker_Data.Employment_Data.Worker_Job_Data[?(@.attributes['wd:Primary_Job'] === '1')].Position_Data.Business_Site_Summary_Data.Name

When running this through the parser, I can see the term evaluates to .Position_Data.Business_Site_Summary_Data.Name. The result I would like to achieve is to get out the full expression: Worker_Data.Employment_Data.Worker_Job_Data[?(@.attributes['wd:Primary_Job'] === '1')].Position_Data.Business_Site_Summary_Data.Name.

My gut feeling is that the formula language is recognizing the '[]' and parses it at something else but looking through the docs I am unclear as to what.

I wonder is someone could shed some light on this for me? If formula uses [] for something else, how can I escape the character when using it in the expression? Also open to other solutions. Please let me know if more details are required.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!