Skip to content

Struct fields conflict when source contains fields which convert to the same name #87

@Manu311

Description

@Manu311

Hi,

I have a json which contains multiple fields which have different fields which are named such that they get converted to the same struct fields.

Here's a minimal example to show this behavior:

{
  "type": "record",
  "name": "my_name",
  "fields": [
    {"name": "field_name", "type": "int"},
    {"name": "fieldName", "type": "string"}
  ]
}

This gets converted to

#[derive(Debug, PartialEq, Eq, Clone, serde::Deserialize, serde::Serialize)]
pub struct MyName {
    #[serde(rename = "fieldName")]
    pub field_name: String,
    #[serde(rename = "fieldName")]
    pub field_name: String,
}

When the order of the fields is inverted, the result is identical, but without the serde-renames and the type of both fields becomes i32.

It would be nice if there was an option in override_field to change the name as well to resolve this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions