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 .
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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: