metosin / jsonista

Clojure library for fast JSON encoding and decoding.
https://cljdoc.org/d/metosin/jsonista
Eclipse Public License 2.0
422 stars 30 forks source link

keywordizing values #65

Open smogstate opened 2 years ago

smogstate commented 2 years ago

Hi, first of all i want to thank you guys, great projects!

We got an issue which we cant explain. Clojure tests, function loads an json which is defined in base64 variable. Works everywhere except jenkins. Dockerfile which is build on jenkins localy works =D

Version of library is used 0.3.6

Code: ` (defn parse "Parse json" [s]

?(:cljs (js->clj (.parse js/JSON s) :keywordize-keys true)

 :clj (j/read-value s (j/object-mapper {:decode-key-fn true}))))

`

First problem we got is that library keywordize string values. even if we turn decode-key-fn then keys are remaining strings and values are keywordized anyway.

Second problem that one json cant be readed at all. Test is exiting with exception:

`

17 20.47 Exception: java.lang.NullPointerException: null

17 20.47 at jsonista.jackson.PersistentHashMapDeserializer.deserialize (PersistentHashMapDeserializer.java:37)

17 20.47 jsonista.jackson.PersistentHashMapDeserializer.deserialize (PersistentHashMapDeserializer.java:19)

17 20.47 com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer.deserialize (UntypedObjectDeserializer.java:246)

17 20.47 jsonista.jackson.PersistentVectorDeserializer.deserialize (PersistentVectorDeserializer.java:27)

17 20.47 jsonista.jackson.PersistentVectorDeserializer.deserialize (PersistentVectorDeserializer.java:15)

17 20.47 com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer.deserialize (UntypedObjectDeserializer.java:254)

17 20.47 jsonista.jackson.PersistentHashMapDeserializer.deserialize (PersistentHashMapDeserializer.java:35)

17 20.47 jsonista.jackson.PersistentHashMapDeserializer.deserialize (PersistentHashMapDeserializer.java:19)

17 20.47 com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer.deserialize (UntypedObjectDeserializer.java:246)

17 20.47 com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose (ObjectMapper.java:4202)

17 20.47 com.fasterxml.jackson.databind.ObjectMapper.readValue (ObjectMapper.java:3205)

17 20.47 com.fasterxml.jackson.databind.ObjectMapper.readValue (ObjectMapper.java:3173)

17 20.47 jsonista.core$eval6033$fn__6034.invoke (core.clj:170)

17 20.47 jsonista.core$eval5998$fn5999$G5989__6006.invoke (core.clj:148)

17 20.47 jsonista.core$read_value.invokeStatic (core.clj:214)

17 20.47 jsonista.core$read_value.invoke (core.clj:204)

17 20.47 glmsweb.token_utils$parse.invokeStatic (token_utils.cljc:14)

`

Wired thing: stack does not match source.

May be you can give us hint what it could be? Like environment variable or something.

smogstate commented 2 years ago

It seems that this NPE raised because in that particular json there is a field with null value, and library try to keywordize it :)