georust/kml

Proper way to put JSON into description

Closed this issue · 1 comments

k-bx commented

I'm trying to generate a <folder>'s <description> tag with contents which have JSON text in them. Currently I did it like this:

            // description; will contain one-line json string
            kml::types::Kml::Element(kml::types::Element {
                name: "description".to_string(),
                content: Some(description_json_s),
                ..Default::default()
            }),

And what I get is a non-valid KML/XML like:

<kml><Document name="All devices"><Folder><name>foo</name><description>&lt;![CDATA[{&quot;foo&quot;:&quot;bar&quot;

How do I properly put it in?

k-bx commented

Apologies, the bug was not in escaping but in incorrect buffered serialization which led to file being truncated