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

124
Views
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 answers
Answer question

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 Report
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!