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

139
Vistas
Generating files in nodejs escape character issue

I have a NestJs project where I am trying to generate js files into the CDN blob storage. For eg I have this object:

{
 "prop1":"${resolvedprop1}",
 "prop2":"John's pet"
}

content of the generated js file should look like:

var metadata=()=>JSON.parse('{ "prop1":"${resolvedprop1}", "prop2":"John's pet" }')

Code for generation of the file:

function writeToCDN(metadata){
    const content = `var metadata = ()=>JSON.parse('${JSON.stringify(metadata)}')`;
    //write content string to a file in CDN BLOB.
}

When I load this file into the browser and execute metadata() I get an error when parsing because the single quote is not escaped.

Important note: I can not use backtick instead of single quote inside JSON.parse since I am expecting ${} in the prop1 value.

Thank you for your help in advance!

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