public function testParseErrorDetectSingleQuotes()
{
$json = '{
\'foo\': "bar"
}';
$this->expectParseException('use double quotes (") instead of single quotes (\') on line 2, char 9', $json);
}
public function testParseErrorDetectMissingQuotes()
{
$json = '{
foo: "bar"
}';
$this->expectParseException('must use double quotes (") around keys on line 2, char 9', $json);
}
public function testParseErrorDetectArrayAsHash()
{
$json = '{
"foo": ["bar": "baz"]
}';
$this->expectParseException('you must use the hash syntax (e.g. {"foo": "bar"}) instead of array syntax (e.g. ["foo", "bar"]) on line 2, char 16', $json);
}
public function testParseErrorDetectMissingComma()
{
$json = '{
"foo": "bar"
"bar": "foo"
}';
$this->expectParseException('missing comma on line 2, char 21', $json);
}
private function expectParseException($text, $json)