Could data.json support UUIDs?

Description

Cheshire provides default formatting for UUIDs out of the box. data.json does not.

Supporting java.util.UUID by just calling str on it seems reasonable.

Environment

None

Activity

Show:
Alex Miller
April 6, 2021, 8:49 PM

Applied for 2.1.0

Erik Assum
April 6, 2021, 5:21 PM

0002-DJSON-39-Support-writing-UUIDs.patch quotes the uuid properly and has a round tripping test.

Sean Corfield
April 6, 2021, 5:11 AM

Right, sorry, I was providing the :value-fn equivalent – which data.json then converts so calling str as a :value-fn on a UUID works, but it is expecting that string to then be formatted as JSON.

Alex Miller
April 6, 2021, 4:48 AM

I'm not sure if my comment here was understood - the uuid is being written without quotes as a json string, which is wrong.

Here it should be written as the string "\"3b17b115-cab9-49e2-93a2-1e5f55435a6f\"", not as "3b17b115-cab9-49e2-93a2-1e5f55435a6f".

Sean Corfield
March 28, 2021, 2:22 AM

This is correct:

That’s exactly what Cheshire does and exactly what our :value-fn does and it “round-trips” just fine as far as JSON is concerned (as a string).

Fixed

Assignee

Alex Miller

Reporter

Sean Corfield