Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not JSON-compatible #1

Closed
GoogleCodeExporter opened this issue Mar 30, 2015 · 3 comments
Closed

Not JSON-compatible #1

GoogleCodeExporter opened this issue Mar 30, 2015 · 3 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Create a new UUID
2. Marshal said UUID
3. Unmarshal the result of 2 into a new UUID

What is the expected output? What do you see instead?

Both UUIDs should be equal. Instead, step 3 throws an Unmarshal error. 
Marshaling occurs as is typical for byte slices--it is encoded as a string--but 
Unmarshaling cannot unmarshal a string to type UUID.

What version of the product are you using? On what operating system?

This was confirmed in Go 1.2rc3 on the Go playground: 
http://play.golang.org/p/BUo5pw9BAO. It is running against the latest master of 
go-uuid, 7dda39b2e7d5.

Please provide any additional information below.

This should be simple enough to fix: extend the UUID type to implement 
Marshaler and Unmarshaler. I would expect them to call json.Marshal on 
id.String() (where id is a UUID), and json.Unmarshal, followed by Parse() on 
the result.

If this were on Github or something similar, I'd submit a pull request. 
Unfortunately, I'm unsure as to how to do that on Google Code. Instead, I've 
implemented a variation on the Go Playground: 
http://play.golang.org/p/OXjK4Jdd7w

This could be implemented by aliasing the UUID type locally an extending it, 
but that seems like a silly wrapper to maintain, rather than adding two 
functions to go-uuid.

Original issue reported on code.google.com by pa...@dramafever.com on 17 Apr 2014 at 5:09

@GoogleCodeExporter
Copy link
Author

I have also ran into this issue.  In my own code I created a wrapper around the 
uuid and had it implement Marshaler and Unmarshaler.  It would be really nice 
to see these implemented for uuid.

Original comment by ryan.mo...@greyrocksoft.com on 20 May 2014 at 3:57

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Thank you, I am starting work on this now.   Apparently I was not seeing mail 
that indicated there were issues with go-uuid.

Original comment by bor...@google.com on 1 Dec 2014 at 5:23

  • Changed state: Started
  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Original comment by bor...@google.com on 1 Dec 2014 at 6:07

  • Changed state: Fixed
  • Added labels: ****
  • Removed labels: ****

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant