Closed becw closed 8 years ago
Hm, I would agree. How do we detect invalid JSON, though? Please file a PR. :-)
We should probably do the same for unparsable XML, too.
Some clues can be found in the examples here http://php.net/manual/en/function.json-last-error.php
For JSON you can consider using seld/jsonlint as that can check to make sure that the JSON is well-formed. It does not help the XML problem.
JSON has been resolved here: https://github.com/Crell/ApiProblem/pull/14
When invalid JSON is passed to
ApiProblem::fromJson()
, I get a PHP notice and an exception:I think it would be appropriate to throw an exception about the invalid JSON, rather than one about the missing title.