this post was submitted on 08 Sep 2023
0 points (50.0% liked)
Rust
6044 readers
5 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
So, no. With the way you have it setup right now you would need to adjust your JSON structure to have the nation info be under a key, as well as the people array.
Every value has to have a key, unless it is the only value being serialized.
Is valid JSON, but
Is not
An untagged enum doesn't need keys for the variants. It just tries to deserialize into each variant in the order defined.
That being said, you're right that the JSON is invalid.
Yeah, I wasn't trying to imply that it was a problem on the rust side or that they needed to name the keys that way, just that the JSON does need to have keys because that is how JSON works