top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to Validate JSON in PHP?

0 votes
312 views
How to Validate JSON in PHP?
posted Jul 15, 2017 by Biswajit Maity

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Suppose a string contains the json string and you want to validate if it is correct as per json standard. Follow the following simple code -

$decoded_json = json_decode($json);
if($decoded_json === null) {
 // $decoded_json is null because json cannot be decoded
}
answer Jul 15, 2017 by Salil Agrawal
...