Skip to content

Add UUID json format#313

Open
atararaksin wants to merge 1 commit into
spray:masterfrom
atararaksin:feature/uuid-format
Open

Add UUID json format#313
atararaksin wants to merge 1 commit into
spray:masterfrom
atararaksin:feature/uuid-format

Conversation

@atararaksin

@atararaksin atararaksin commented Jul 29, 2019

Copy link
Copy Markdown

This PR adds an instance of JsonFormat[UUID] as requested in #243.
I'm not sure as to where to place this object, currently BasicFormats is my best guess, but feel free to request any changes.

Closes #243

@plokhotnyuk

plokhotnyuk commented Jul 29, 2019

Copy link
Copy Markdown

@atararaksin UUID.fromString behaves differently on different versions of Java and allows illegal (or non standart) string values...

Please consider to pick a more efficient and stable implementation, like here or here

@atararaksin

Copy link
Copy Markdown
Author

@plokhotnyuk Thanks for pointing that out. I guess including fast-uuid as an external dependency is not a good option. Would it be appropriate (e.g. from the legal perspective) to borrow the implementation from jsoniter-scala?

@plokhotnyuk

Copy link
Copy Markdown

@atararaksin 1st one (from fast-uuid) is for sequences of characters.

While 2nd one (from jsoniter-scala) is for array of bytes - feel free to reuse if you will find something suitable there.

@Philippus

Philippus commented Jul 31, 2019

Copy link
Copy Markdown

This addition should make sure that uuid's follow RFC 4122, have a look at akka/akka-http#2569 and akka/akka-http#2596 for inspiration.

@plokhotnyuk

plokhotnyuk commented Jul 31, 2019

Copy link
Copy Markdown

@Philippus IMHO validation of the hexadecimal representation with dashes is enough... and limiting of allowed Msb bits will broke backward compatibility with NCS and custom extensions.

Also, using of regexp for that can be revised for more efficient implementation

@Philippus Philippus left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ProblemFilters.exclude[ReversedMissingMethodProblem]("spray.json.BasicFormats.UUIDJsonFormat") needs to be added to the mimaBinaryIssueFilters-setting in build.sbt.

@jrudolph jrudolph changed the base branch from master to release/1.3.x November 10, 2020 09:43
@jrudolph jrudolph changed the base branch from release/1.3.x to master November 10, 2020 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Json Format for java.util.UUID

3 participants