dakrone / cheshire

Clojure JSON and JSON SMILE (binary json format) encoding/decoding

Home Page:https://github.com/dakrone/cheshire

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Automatic keywordization; is it dangerous

wiseman opened this issue · comments

(cheshire.core/parse-string "{\"1 23\": 4}" true) => {:1 23 4}

That's certainly not a keyword that the clojure reader will let you create; is that OK? If it is, then cool. if it's not, then maybe the default keywordizer function should do something different.

it's "okay" if you're not serializing/deserializing that keyword.

I don't think there's any other reasonable behavior (since the user is explicitly asking for keywordization) other than throwing an exception, but I'm not sure that keyword syntax is formally defined enough to know when to throw an exception.

Yeah, +1 to what @gfredericks said, you also have control over whether to use keywords or not, so I don't consider it too dangerous

OK. I was wondering specifically whether the behavior of the default keywordizer would encourage people to do unsafe things, but I guess if you're just ingesting JSON, or serializing out as JSON/YAML etc. you're OK, and those are probably the most common cases.

The issue would come up if, for example, you try to serialize as EDN, and EDN has this issue regardless of whether you've used cheshire to create the data, if that makes sense.