is there any way to validate a string to be json or not ? other than try/catch .
I'm using ServiceStack Json Serializer and couldn't find a method related to validation .
is there any way to validate a string to be json or not ? other than try/catch .
I'm using ServiceStack Json Serializer and couldn't find a method related to validation .
A working code snippet
Source
Probably the quickest and dirtiest way is to check if the string starts with '{':
Another option is that you could try using the JavascriptSerializer class:
Or you could have a look at JSON.NET:
You can find a couple of regular expressions to validate JSON over here: Regex to validate JSON
It's written in PHP but should be adaptable to C#.