Comments (2)
Thanks for helping out with this @TylerBloom 👍
There hasn't been any activity here for a while so I'll go ahead and close this one, but please feel free to open new issues with anything else you encounter.
from uuid.
Your issue is that a UUID (in JSON) is a string. You can see this if you perform the following test:
let id = uuid!("f4a9a11b-6e71-443d-9289-71a26fe6a018");
let s_id = serde_json::to_string(&id).unwrap();
// This check will fail
assert_eq!(s_id, "f4a9a11b-6e71-443d-9289-71a26fe6a018");
If you run this, you will get the following error:
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `"\"f4a9a11b-6e71-443d-9289-71a26fe6a018\""`,
right: `"f4a9a11b-6e71-443d-9289-71a26fe6a018"`'
However, you don't need to use serde_json
. You can use Uuid::from_str
to achieve what you want. The following runs without issue:
let id = uuid!("f4a9a11b-6e71-443d-9289-71a26fe6a018");
let from_str_id = Uuid::from_str("f4a9a11b-6e71-443d-9289-71a26fe6a018").unwrap();
assert_eq!(from_str_id, id);
Hope this helps!
from uuid.
Related Issues (20)
- Add reordering to convert between v1 and v6 UUIDs HOT 2
- Implement FromParam trait for Uuid from the Rocket web framework crate HOT 1
- Add compatibility with rocket HOT 1
- regression(?): Pretty debug printing now strips hyphens
- Compilation error with wasm_bindgen HOT 2
- Parsing error mentions incorrect characters as expected
- `cargo install uuid` should give me a uuid tool HOT 5
- Cleaning up crate features HOT 3
- Add `.as_str()` for Uuid HOT 2
- Simple Encode / Decode HOT 2
- Fix MSRV build
- `Timestamp::from_rfc4122` panics when using timestamp before unix epoch HOT 4
- About UUID v7 implementation HOT 1
- Optional support for borsh
- Wasm32-unknown-unknown tests not running
- 1.3.4 and 1.3.3 failing in Cloudflare Worker env for different reasons
- Unable to activate feature "v7" HOT 6
- Request: add configuration to enable/disable deserializing different formats HOT 2
- Wrapping behavior of `impl ClockSequence for Context` HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uuid.