Seldaek/jsonlint

Integers marked as valid JSON

hdezela opened this issue · 3 comments

LIke the title says, if you pass an integer $parser->lint(INT);, it validates as correct.

stof commented

Well, the JsonParser documents its input as being a string (it would be typehinted if PHP 7 was required). This means that passing an int is actually linting a string containing this int (which is exactly what would happen with scalar type hints btw), and this is valid JSON (try to run json_encode(150))

I guess I'm just used to JSON beginning with [ or {

Just checked the spec and you're right...killing the issue.

stof commented

Well, it is true that we often represent more complex data in JSON rather than scalars, but this does not make them invalid 😄