Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle null and empty string #37

Open
maxsatula opened this issue Apr 14, 2021 · 0 comments
Open

Handle null and empty string #37

maxsatula opened this issue Apr 14, 2021 · 0 comments

Comments

@maxsatula
Copy link

This example

require('dirty-json').parse(null)

Returns null as expected, but whines every time:

dirty-json got valid JSON that failed with the custom parser. We're returning the valid JSON, but please file a bug report here: https://github.com/RyanMarcus/dirty-json/issues -- the JSON that caused the failure was: null

Passing an empty string throws an exception:

require('dirty-json').parse("")

Uncaught TypeError: Cannot read property 'type' of undefined

It is negotiable though what is supposed to be returned instead of an exception. An empty string or an empty object?

Also, passing undefined (not sure who might want that) gives another exception

require('dirty-json').parse(undefined)

Uncaught TypeError: Cannot read property 'length' of undefined

Not sure if you want to handle undefined at all, I just checked it for no apparent reason while creating this issue. Also, boolean values (I know, this module is supposed to process strings, what am I talking about) have the same behavior as null, the same value returned, but with a warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant