Skip to content

Instantly share code, notes, and snippets.

@egulhan
Created April 14, 2015 09:16
Show Gist options
  • Save egulhan/bc7f93aeb65ba1b4c623 to your computer and use it in GitHub Desktop.
Save egulhan/bc7f93aeb65ba1b4c623 to your computer and use it in GitHub Desktop.
Determine if string is json encoded or not using PHP
<?php
function isJsonEncoded($str)
{
json_decode($str);
return json_last_error() == JSON_ERROR_NONE ? true : false;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment