dakrone/cheshire — Issue #15: difference with clojure.contrib.json on backslash escaping
Author: mpenet
Created: 2012-01-18 09:25:53+00:00
State: open

Hello,

clojure.contrib.json escapes backslashes by default, even though it is not a standard feature Jackson supports this as well through http://jackson.codehaus.org/1.9.0/javadoc/org/codehaus/jackson/JsonParser.Feature.html#ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER

Here is an example that illustrates the issue:

```clojure
(use 'cheshire.core)
(generate-string {:url "http://example.com/"})
"{\"url\":\"http://example.com/\"}"

(use 'clojure.contrib.json)
(json-str {:url "http://example.com/"})
"{\"url\":\"http:\\/\\/example.com\\/\"}"

Most of the time the default jackson behavior is fine, but if your json is embedded in an html page for instance and it contains an HTML tag (like script, unescaped in json will be parsed as the closing tag of the script container before the real one), this can cause some headaches.

A possible solution would be to enable this feature by default, matching json-str behavior.

What so you think about this?