boonproject / boon

Simple opinionated Java for the novice to expert level Java Programmer. Low Ceremony. High Productivity.
http://richardhightower.github.io/site/Boon/Welcome.html
Apache License 2.0
520 stars 102 forks source link

toJson(readValue) does not return expected value #384

Closed rzorzorzo closed 4 years ago

rzorzorzo commented 4 years ago

String json1 = "{\"1\":{\"2\":[\"3\"]}}"; System.out.println(json1); ObjectMapper mapper = ObjectMapperFactory.create(); Map map = mapper.readValue(json1.getBytes(), Map.class); System.out.println(map); String json2 = mapper.toJson(map); System.out.println(json2);

outputs:

{"1":{"2":["3"]}} {1={2=[3]}} {"map":{"1":{"map":{"2":{"list":["3"],"lazyChop":true,"converted":true,"MAX_ARRAY_SIZE":1}},"lazyChop":true}},"lazyChop":true}`

why not ?

{"1":{"2":["3"]}}

Further :

mapper.readValue(json1.getBytes(), HashMap.class);

returns an empty map.

I have searched this for some hours now, but could not find anything in the docs.

rzorzorzo commented 4 years ago

PS: I was using release 0.7 instead of the newest one.