Json schema ,check double quotes start and end of the string

Viewed 26

I have a json property Employee-name which contains a string with double quotes at the start and end like this:

"ramesh yadav"

I have a schema.json file to validate schema of my json data.

I wanna know how I can write regular expression inside schema file so it will check for double quotes

"Employee-name": {
  "type":"string",
  "pattern":??????
}
1 Answers

You use the line start (^) and end ($) regex operands together with escaped (via \) double quotes to make the regex a valid JSON string. All put together, the following should work:

{
  "properties": {
    "Employee-name":{
      "type":"string",
      "pattern": "^\".*\"$"
    }
  }
}
Related