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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

read-value fails on empty string #31

Open
fmnoise opened this issue May 18, 2020 · 2 comments
Open

read-value fails on empty string #31

fmnoise opened this issue May 18, 2020 · 2 comments

Comments

@fmnoise
Copy link

fmnoise commented May 18, 2020

(j/read-value "")
; => Exception: com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input

Is that intentional? Cheshire returns nil for such case. Maybe that can be tuned with object-mapper? 馃

@fmnoise fmnoise changed the title Reading fails on empty string read-value fails on empty string May 18, 2020
@fmnoise
Copy link
Author

fmnoise commented May 18, 2020

Ahh, I see, empty string is not valid JSON, so probably jsonista implementation is more correct than cheshire.
Good way to see if your project code if JSON-compliant though 馃う

@ikitommi
Copy link
Member

Yes, it's a property of Jackson. There are lot of features that can be set, but with a quick test, at least this doesn't work:

(def allow-nil-object-mapper 
  (doto (j/object-mapper) 
    (.enable com.fasterxml.jackson.databind.DeserializationFeature/ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)))

(j/read-value "" allow-nil-object-mapper)
; Execution error (MismatchedInputException) at com.fasterxml.jackson.databind.exc.MismatchedInputException/from (MismatchedInputException.java:59).
; No content to map due to end-of-input
;  at [Source: (String)""; line: 1, column: 0]

Would also like to know if there is existing thing for this in Jackson or would it require custom Java/Clojure code in jsonista.

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

No branches or pull requests

2 participants