mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-06-01 09:42:41 +00:00
fix: add xml utf8 and semver declaration
This commit is contained in:
parent
4675b24ff3
commit
48aa5115c0
1 changed files with 4 additions and 1 deletions
|
|
@ -279,7 +279,7 @@ fn output_result_json_pretty<T: serde::Serialize>(result: T) -> Result<()> {
|
||||||
#[cfg(feature = "xml")]
|
#[cfg(feature = "xml")]
|
||||||
fn output_result_xml<T: serde::Serialize>(result: T) -> Result<()> {
|
fn output_result_xml<T: serde::Serialize>(result: T) -> Result<()> {
|
||||||
use quick_xml::{
|
use quick_xml::{
|
||||||
events::{BytesEnd, BytesStart, BytesText, Event},
|
events::{BytesDecl, BytesEnd, BytesStart, BytesText, Event},
|
||||||
Writer,
|
Writer,
|
||||||
};
|
};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
@ -292,6 +292,9 @@ fn output_result_xml<T: serde::Serialize>(result: T) -> Result<()> {
|
||||||
// Initialize the XML writer with a new, empty vector to store the XML data.
|
// Initialize the XML writer with a new, empty vector to store the XML data.
|
||||||
let mut writer = Writer::new(Vec::new());
|
let mut writer = Writer::new(Vec::new());
|
||||||
|
|
||||||
|
// Write the XML 1.1 declaration
|
||||||
|
writer.write_event(Event::Decl(BytesDecl::new("1.1", Some("utf-8"), None)))?;
|
||||||
|
|
||||||
// Define a recursive function `json_to_xml` to convert the JSON value into XML
|
// Define a recursive function `json_to_xml` to convert the JSON value into XML
|
||||||
// format. The function takes a mutable reference to the XML writer, an
|
// format. The function takes a mutable reference to the XML writer, an
|
||||||
// optional key as a string slice, and a reference to the JSON value to be
|
// optional key as a string slice, and a reference to the JSON value to be
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue