Output of the "Checking if a string contains valid JSON with PHP" PHP snippet

Environment:

  • Strangebuzz Snippet VM: 6.4.2
  • PHP: 8.3

Code execution output:

NO, >foo< is NOT a valid JSON string: Syntax error
NO, >{foo: bar}< is NOT a valid JSON string: Syntax error
NO, >'{'foo': 'bar'}< is NOT a valid JSON string: Syntax error
NO, >{...}< is NOT a valid JSON string: Syntax error
YES, >"foo"< is a valid JSON string
decoded: 'foo'
YES, >1< is a valid JSON string
decoded: 1
YES, >{"foo": "bar"}< is a valid JSON string
decoded: (object) array(
   'foo' => 'bar',
)