I don't get it, this is not valid JSON.
Rust
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)
It should be wrapped in an array, not an object. Then it's valid. The problem was that I was trying to use an enum.
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.
{
"Nation": {...},
"People": [...],
}
Every value has to have a key, unless it is the only value being serialized.
[1,2]
Is valid JSON, but
{ {"Id":1} }
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
This is not valid JSON.
Does the People(Vec) even work if you don't specify the type inside the Vec?
Lemmy loves to remove things that look like HTML tags :/
What are you deserializing into? Minimum reproducible Code would be best. That means a main.rs file with a main method and no dependencies, which prints your error when run. Then you can simply share it on the rust playground or ideone.com.
I believe the JSON you have given us is invalid. Either the outer most parentheses must be [] instead of {}, or the nation and the list must get a name, i.e. "nation" = {"id"= 1, "country"="USA"}, "people"= []