I have the JSON roughly like this:
[
{
"commonA": 1,
"commonB": 2,
"type": "Foo",
"fooSpecificA": 3,
"fooSpecificB": 4
},
{
"commonA": 5,
"commonB": 6,
"type": "Bar",
"barSpecificA": 7,
"barSpecificB": 8
},
...
In other words I have internally tagged objects, but some of the fields are common to every type. I'd like to deserialise it to something like this:
struct Entry {
commonA: i64,
commonB: i64,
variant: EntryVariant,
}
enum EntryVariant {
Foo(FooSpecific),
Bar(BarSpecific),
}
struct FooSpecific {
fooSpecificA: i64,
fooSpecificB: i64,
}
struct BarSpecific {
barSpecificA: i64,
barSpecificB: i64,
}
Is that possible with Serde?
snake_case
for variables, methods, macros, fields and modules;UpperCamelCase
for types and enum variants; andSCREAMING_SNAKE_CASE
for statics and constants. – Stock#[rename_all()]
attributes would have made the example less clear. – Sporulate