media-io / yaserde

Yet Another Serializer/Deserializer
MIT License
174 stars 58 forks source link

Attribute and element with same name #163

Open KrullBorg opened 10 months ago

KrullBorg commented 10 months ago

i have a simple xml where there are an attribute and an inner element with the same name and i get the error conflicting implementations of trait "yaserde::Visitor<'_>" for type "_IMPL_YA_DESERIALIZE_FOR..."

<car type="suv">
  <type>new</type>
</car>

is it possible to parse it with yaserde?

thanks in advance

MarcAntoine-Arnaud commented 5 months ago

Hi @KrullBorg ,

I have addressed this case in https://github.com/media-io/yaserde/commit/9c2d04b0afe039e88f80d65f746834dc007a1d08

Please check with YaSerDe version > 9.2.

Just to be sure, you have to use the rename like:

struct Car {
  #[yaserde(attribute, rename = "type")]
  field1: String,
  #[yaserde(rename = "type")]
  field2: String,
} 

Enjoy !