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

127
Vistas
Passing Regex string in JSON body

I am trying to send regex string in JSON body of my http request like this

{
  "pattern":"\b\d{8}\b"
}

But I get a 400 response from the server

Unexpected token d in JSON at position xxx

If I try to escape the "\" in the JSON body like

{
  "pattern":"\b\\d{8}\b"
}

The server doesn't throw any error but the request body received in the server end is incorrect

Expectation: 
{
  "pattern":"\b\d{8}\b"
}

Result:
{
  "pattern":"\b\\d{8}\b"
}

Any inputs or references will be helpful.

Thanks,

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Did you trying sending as string First in requesting side

JSON.stringify({ "pattern":"\b\\d{8}\b" })

in controller side

public class myregex
{
    public string pattern{ get; set; }
}
JsonConvert.DeserializeObject<myregex>(json) 
about 4 years ago · Juan Pablo Isaza Denunciar
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