Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

162
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda