Andy
Andy

Reputation: 2603

How to fix Validation error in a JSON string with special chars

I have a following JSON string:

{
    "my_regex": "(?<somevalue>^(\S*\s*\S*)*$)"
}

When I try to validate the format using online tools like jsonlint, I get following error:

Error: Parse error on line 2:

..."object_condition": "(?^(\S*

-----------------------^

Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got >'undefined'


So my question is, what should I do to make it a valid JSON?

Upvotes: 1

Views: 140

Answers (1)

ceferrari
ceferrari

Reputation: 1677

You need to escape the \'s:

{
    "my_regex": "(?<somevalue>^(\\S*\\s*\\S*)*$)"
}

jsonlint :

enter image description here

Upvotes: 2

Related Questions