Skip to content

Commit

Permalink
release 1.0.0
Browse files Browse the repository at this point in the history
- switching to maintained quick-xml library for XML deserialization
- bump quick-xml from 0.31.0 to 0.36.1
- preserve document root node, fixes #48
  • Loading branch information
simonrupf committed Aug 3, 2024
1 parent c177084 commit c055ff4
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 69 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
Change Log of convert2json utilities
====================================

Version 1.0.0 / 2024-08-03
--------------------------
- switching to maintained quick-xml library for XML deserialization
This is a major, breaking change and the resulting JSON will have a different
structure. In particular:
- document root node gets preserved as the outermost objects only key (#48):
`<root/>` becomes `{"root": {}}` (instead of `{}`)
- attributes start with an @-character to distinguish them from inner tags:
`<tag attribute="value"><inner/></tag>` becomes
`{"tag":{"@attribute":"value","inner":{}}}`
(instead of `{"attribute":"value","inner":{}}`)
- text nodes are now called `$text` instead of `$value`:
`<key>value</key>` becomes `{"key":{"$text":"value"}}`
(instead of `{"$value":"value"}`)

Version 0.9.3 / 2024-08-03
--------------------------
- bump serde_json from 1.0.120 to 1.0.122
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ required-features = ["yq"]
[dependencies]
csv = { version = "1.3.0", optional = true }
pico-args = { version = "0.5.0", features = ["short-space-opt"], optional = true }
quick-xml = { version = "0.31.0", features = ["serialize"], optional = true }
quick-xml = { version = "0.36.1", features = ["serialize"], optional = true }
rsv-core = { version = "0.0.4", optional = true }
serde = { version = "1.0.204", features = ["serde_derive"] }
serde_ini = { version = "0.2.0", optional = true }
Expand Down
99 changes: 35 additions & 64 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ This document lists the licenses of the projects used in convert2json.

## Overview of licenses

- [Apache License 2.0](#Apache-2.0) (21)
- [MIT License](#MIT) (13)
- [Apache License 2.0](#Apache-2.0) (20)
- [MIT License](#MIT) (12)
- [Unicode License Agreement - Data Files and Software (2016)](#Unicode-DFS-2016) (1)

## Full license texts
Expand Down Expand Up @@ -427,7 +427,6 @@ END OF TERMS AND CONDITIONS
- [equivalent](https://github.com/cuviper/equivalent) 1.0.1
- [hashbrown](https://github.com/rust-lang/hashbrown) 0.14.3
- [indexmap](https://github.com/indexmap-rs/indexmap) 2.2.2
- [log](https://github.com/rust-lang/log) 0.4.20

```
Apache License
Expand Down Expand Up @@ -772,36 +771,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
```
### <a id="MIT"></a>MIT License

#### Used by

- [serde-xml-rs](https://github.com/RReverser/serde-xml-rs) 0.6.0

```
MIT License
Copyright (c) 2017 Ingvar Stepanyan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the &quot;Software&quot;), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
### <a id="MIT"></a>MIT License

Expand Down Expand Up @@ -855,7 +824,7 @@ THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRES

#### Used by

- [convert2json](https://github.com/simonrupf/convert2json) 0.9.3
- [convert2json](https://github.com/simonrupf/convert2json) 1.0.0
- [unsafe-libyaml](https://github.com/dtolnay/unsafe-libyaml) 0.2.11

```
Expand Down Expand Up @@ -915,36 +884,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

#### Used by

- [xml-rs](https://github.com/kornelski/xml-rs) 0.8.19

```
The MIT License (MIT)
Copyright (c) 2014 Vladimir Matveev
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the &quot;Software&quot;), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
### <a id="MIT"></a>MIT License

#### Used by

- [csv-core](https://github.com/BurntSushi/rust-csv) 0.1.11
- [csv](https://github.com/BurntSushi/rust-csv) 1.3.0
- [memchr](https://github.com/BurntSushi/memchr) 2.7.1
Expand Down Expand Up @@ -972,6 +911,38 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
```
### <a id="MIT"></a>MIT License

#### Used by

- [quick-xml](https://github.com/tafia/quick-xml) 0.36.1

```
The MIT License (MIT)
Copyright (c) 2016 Johann Tuffe
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the &quot;Software&quot;), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
```
### <a id="Unicode-DFS-2016"></a>Unicode License Agreement - Data Files and Software (2016)

Expand Down
5 changes: 4 additions & 1 deletion src/bin/xml2json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
extern crate quick_xml;
use convert2json::json::{parse_args, stdout_writer};
use convert2json::to_value;
use convert2json::xml::wrap_xml_reader;

fn main() {
for reader in parse_args() {
stdout_writer(to_value(&quick_xml::de::from_reader(reader)));
stdout_writer(to_value(&quick_xml::de::from_reader(wrap_xml_reader(
reader,
))));
}
}
5 changes: 4 additions & 1 deletion src/bin/xq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
extern crate quick_xml;
use convert2json::jq::{parse_args, readers, Jq};
use convert2json::to_value;
use convert2json::xml::wrap_xml_reader;

fn main() {
let (arguments, files) = parse_args();
let mut jq = Jq::new(&arguments);
for reader in readers(&files) {
jq.write(to_value(&quick_xml::de::from_reader(reader)));
jq.write(to_value(&quick_xml::de::from_reader(wrap_xml_reader(
reader,
))));
}
}
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pub mod csv;
pub mod jq;
pub mod json;
pub mod string;
pub mod xml;
pub mod yaml;

extern crate serde_json;
Expand Down
14 changes: 14 additions & 0 deletions src/xml.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#![cfg(any(feature = "xml", feature = "xml2json", feature = "xq"))]
use std::io::{BufReader, Chain, Read};

static READER_PREFIX: &[u8] = b"<ignored>";
static READER_SUFFIX: &[u8] = b"</ignored>";

type RootNodePreservingReader<R> =
Chain<Chain<BufReader<&'static [u8]>, R>, BufReader<&'static [u8]>>;

pub fn wrap_xml_reader<R: Read>(reader: R) -> RootNodePreservingReader<R> {
let prefix_reader = BufReader::new(READER_PREFIX);
let suffix_reader = BufReader::new(READER_SUFFIX);
prefix_reader.chain(reader).chain(suffix_reader)
}

0 comments on commit c055ff4

Please sign in to comment.