Skip to content

Twice encoded json as string value is parsed incorrectly #36

@bsless

Description

@bsless

Hello,
I'm aware this is an esoteric edge case, so I'll totally understand if it's labelled won't fix, but it's illustrated by the following contrived example:

Create input:

(def input
  (->
   {:regular "hello"
    :very-jsonified (cheshire.core/generate-string {:internal (cheshire.core/generate-string {:a 1})})
    :jsonified (cheshire.core/generate-string {:a 1})
    :another "spam"}
   (cheshire.core/generate-string)))

Parsed correctly with cheshire:

(cheshire.core/parse-string input)
;; =>
{"regular" "hello",
 "very-jsonified" "{\"internal\":\"{\\\"a\\\":1}\"}",
 "jsonified" "{\"a\":1}",
 "another" "spam"}

Parsed incorrectly with pjson:

(pjson.core/read-str input)
;; =>
{"regular" "hello",
 "very-jsonified" "{\"internal\":\"{\\",
 "a\\" ":1}\"}",
 "jsonified" "{\"a\":1}",
 "another" "spam"}

Thanks for taking the time

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions