Open kaedwen opened 3 years ago
I need to prefix some elements with a namespace therefore I use prefix, but in some cases it is not prepended.
prefix
namespace
Here is my model
use std::io::Write; use yaserde::YaSerialize; #[derive(Debug, Default, YaSerialize)] #[yaserde(rename = "infrastructure")] pub struct Infrastructure { #[yaserde(attribute)] pub id: String, #[yaserde(rename = "scopes", prefix: "aaa")] pub scopes: Vec<Scope>, } #[derive(Debug, Default, YaSerialize)] #[yaserde(rename = "scopes", prefix: "aaa")] pub struct Scope { #[yaserde(rename = "scopeRadius", prefix = "aaa")] pub scope_radius: Vec<ScopeValue>, #[yaserde(rename = "scopeDistance", prefix = "aaa")] pub scope_distance: Vec<ScopeValue>, } #[derive(Debug, Default, YaSerialize)] #[yaserde()] pub struct ScopeValue { #[yaserde(attribute, rename = "type")] pub r#type: ScopeType, #[yaserde(attribute)] pub value: u32, } #[allow(unused)] #[derive(Debug, PartialEq, YaSerialize)] #[yaserde()] pub enum ScopeType { #[yaserde(rename = "snap")] Snap, #[yaserde(rename = "inner")] Inner, #[yaserde(rename = "outer")] Outer } impl Default for ScopeType { fn default() -> ScopeType { ScopeType::Snap } }
and the serialized outcome
<infrastructure id="test123"> <scopes> <aaa:scopeRadius type="snap" value="100" /> <aaa:scopeRadius type="inner" value="100" /> <aaa:scopeRadius type="outer" value="500" /> <aaa:scopeDistance type="snap" value="100" /> <aaa:scopeDistance type="inner" value="100" /> <aaa:scopeDistance type="outer" value="300" /> </scopes> </infrastructure>
scopeRadius and scopeDistance is prefixed, but I need scopes to be prefix as well
scopeRadius
scopeDistance
scopes
This happens when serializing a Vec. Then prefix is ignored somehow.
Vec
I need to
prefix
some elements with anamespace
therefore I useprefix
, but in some cases it is not prepended.Here is my model
and the serialized outcome
scopeRadius
andscopeDistance
is prefixed, but I needscopes
to be prefix as well