-
Notifications
You must be signed in to change notification settings - Fork 265
Open
Labels
enhancementhelp wantedserdeIssues related to mapping from Rust types to XMLIssues related to mapping from Rust types to XML
Description
My apologies if this is an inappropriate place to raise this issue.
I have the following structure that I am trying to serialize:
use serde::Serialize;
/// `Description` field for `Tag`.
#[derive(Serialize)]
pub(super) struct Description {
#[serde(rename = "$value")]
value: String,
}
impl Description {
/// Create a new `Description`.
pub(super) fn new(input: &str) -> Self {
let value = format!("<![CDATA[{}]]>", input);
Self { value }
}
}
As you can see I'm wrapping it in CDATA
as per a file format that I'll be writing that I have no control over. This structure is actually just part of a larger structure:
#[derive(Serialize)]
#[serde(rename_all = "PascalCase")]
pub(crate) struct Tag {
name: String,
tag_type: TagType,
data_type: DataType,
dimensions: Option<usize>,
radix: Radix,
constant: Constant,
external_access: ExternalAccess,
description: Description,
}
impl Tag {
/// Return an XML `String` representation of `Tag`.
pub(crate) fn to_xml(&self) -> Result<String, DeError> {
to_string(self)
}
}
Which is serializing perfectly (except for the description field):
<Tag Name="test_dint" TagType="Base" DataType="DINT" Radix="Decimal" Constant="false" ExternalAccess="Read Only"><Description><![CDATA[Test DINT]]></Description></Tag>
It looks like when it serializes the CDATA portion is being escaped:
<Description><![CDATA[Test DINT]]></Description>
Is there anything I can do to unescape it ?
p-kuen and Chaoses-Ib
Metadata
Metadata
Assignees
Labels
enhancementhelp wantedserdeIssues related to mapping from Rust types to XMLIssues related to mapping from Rust types to XML