Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

125
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda