xml2json-rb 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Cargo.lock +28 -16
- data/ext/xml2json/Cargo.toml +5 -2
- data/ext/xml2json/src/lib.rs +54 -110
- data/lib/xml2json/version.rb +1 -1
- data/lib/xml2json.rb +56 -6
- metadata +190 -9
- data/lib/xml2json/xml2json.so +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef6f85b883fb1df89aa98b03908137ce38568434f4ac1c84456da42be613e636
|
4
|
+
data.tar.gz: c519a3d628e6e07356bd0892eeed6e13e3775423c21350d46e4cf59464eb50d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e7c60d98d3d92e3570c928cd05c257845aea1073ded6dcdeff7fd731808d9f38b17f0919cbb2fa9ef4679c7ce233b7ef9c0fa5ff12d761b0286c65525bd8bd8
|
7
|
+
data.tar.gz: d5da3cd90ca19975c7d933b14ffe6ac442faf6069916cf79accdf2ed90508aa04126d749494789c30fcc2b7c991f71422d48001a8248102da5cce0207f54ca4c
|
data/Cargo.lock
CHANGED
@@ -13,9 +13,9 @@ dependencies = [
|
|
13
13
|
|
14
14
|
[[package]]
|
15
15
|
name = "bindgen"
|
16
|
-
version = "0.
|
16
|
+
version = "0.66.1"
|
17
17
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
18
|
-
checksum = "
|
18
|
+
checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7"
|
19
19
|
dependencies = [
|
20
20
|
"bitflags",
|
21
21
|
"cexpr",
|
@@ -28,14 +28,14 @@ dependencies = [
|
|
28
28
|
"regex",
|
29
29
|
"rustc-hash",
|
30
30
|
"shlex",
|
31
|
-
"syn",
|
31
|
+
"syn 2.0.32",
|
32
32
|
]
|
33
33
|
|
34
34
|
[[package]]
|
35
35
|
name = "bitflags"
|
36
|
-
version = "
|
36
|
+
version = "2.4.1"
|
37
37
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
38
|
-
checksum = "
|
38
|
+
checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
|
39
39
|
|
40
40
|
[[package]]
|
41
41
|
name = "cexpr"
|
@@ -127,9 +127,9 @@ dependencies = [
|
|
127
127
|
|
128
128
|
[[package]]
|
129
129
|
name = "magnus"
|
130
|
-
version = "0.
|
130
|
+
version = "0.5.5"
|
131
131
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
132
|
-
checksum = "
|
132
|
+
checksum = "5b7a37670bc433d081ef5846d5589381fabd8d3410ad3b59faa6b1b4c9c3cbce"
|
133
133
|
dependencies = [
|
134
134
|
"magnus-macros",
|
135
135
|
"rb-sys",
|
@@ -138,13 +138,13 @@ dependencies = [
|
|
138
138
|
|
139
139
|
[[package]]
|
140
140
|
name = "magnus-macros"
|
141
|
-
version = "0.
|
141
|
+
version = "0.4.1"
|
142
142
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
143
|
-
checksum = "
|
143
|
+
checksum = "6cc17af1d45442c011aa579d727ec6cff8a69aea8a6bbad26736e7112d749bfb"
|
144
144
|
dependencies = [
|
145
145
|
"proc-macro2",
|
146
146
|
"quote",
|
147
|
-
"syn",
|
147
|
+
"syn 1.0.109",
|
148
148
|
]
|
149
149
|
|
150
150
|
[[package]]
|
@@ -204,18 +204,18 @@ dependencies = [
|
|
204
204
|
|
205
205
|
[[package]]
|
206
206
|
name = "rb-sys"
|
207
|
-
version = "0.9.
|
207
|
+
version = "0.9.82"
|
208
208
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
209
|
-
checksum = "
|
209
|
+
checksum = "a3e6bf79bf4c711917cacfaf46dfab4314dbfdd89a8ee3ec4b98336cd23f1ebf"
|
210
210
|
dependencies = [
|
211
211
|
"rb-sys-build",
|
212
212
|
]
|
213
213
|
|
214
214
|
[[package]]
|
215
215
|
name = "rb-sys-build"
|
216
|
-
version = "0.9.
|
216
|
+
version = "0.9.82"
|
217
217
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
218
|
-
checksum = "
|
218
|
+
checksum = "5482a1ed4cde58dddaf162b6aebcb5c25645822547832b8be101f2acd40bcdd6"
|
219
219
|
dependencies = [
|
220
220
|
"bindgen",
|
221
221
|
"lazy_static",
|
@@ -223,7 +223,7 @@ dependencies = [
|
|
223
223
|
"quote",
|
224
224
|
"regex",
|
225
225
|
"shell-words",
|
226
|
-
"syn",
|
226
|
+
"syn 2.0.32",
|
227
227
|
]
|
228
228
|
|
229
229
|
[[package]]
|
@@ -314,6 +314,17 @@ dependencies = [
|
|
314
314
|
"unicode-ident",
|
315
315
|
]
|
316
316
|
|
317
|
+
[[package]]
|
318
|
+
name = "syn"
|
319
|
+
version = "2.0.32"
|
320
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
321
|
+
checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2"
|
322
|
+
dependencies = [
|
323
|
+
"proc-macro2",
|
324
|
+
"quote",
|
325
|
+
"unicode-ident",
|
326
|
+
]
|
327
|
+
|
317
328
|
[[package]]
|
318
329
|
name = "unicode-ident"
|
319
330
|
version = "1.0.10"
|
@@ -344,9 +355,10 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
|
344
355
|
|
345
356
|
[[package]]
|
346
357
|
name = "xml2json"
|
347
|
-
version = "0.3.
|
358
|
+
version = "0.3.2"
|
348
359
|
dependencies = [
|
349
360
|
"magnus",
|
361
|
+
"rb-sys",
|
350
362
|
"xml2json-rs",
|
351
363
|
]
|
352
364
|
|
data/ext/xml2json/Cargo.toml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
[package]
|
2
2
|
name = "xml2json"
|
3
|
-
version = "0.3.
|
3
|
+
version = "0.3.2"
|
4
4
|
edition = "2021"
|
5
5
|
authors = ["uvlad7 <uvlad7@gmail.com>"]
|
6
6
|
license = "MIT"
|
@@ -10,5 +10,8 @@ publish = false
|
|
10
10
|
crate-type = ["cdylib"]
|
11
11
|
|
12
12
|
[dependencies]
|
13
|
-
magnus = { version = "0.
|
13
|
+
magnus = { version = "0.5.5", features = ["rb-sys-interop"] }
|
14
|
+
rb-sys = { version = "*", default-features = false, features = [
|
15
|
+
"stable-api-compiled-fallback",
|
16
|
+
] }
|
14
17
|
xml2json-rs = "1.0.1"
|
data/ext/xml2json/src/lib.rs
CHANGED
@@ -1,19 +1,26 @@
|
|
1
|
-
use magnus::{define_module, function, prelude::*, Error, Value};
|
2
|
-
use magnus::scan_args::{scan_args};
|
1
|
+
use magnus::{define_module, scan_args::scan_args, function, prelude::*, Error, TryConvert, Value};
|
3
2
|
use xml2json_rs::{XmlBuilder, JsonBuilder, JsonConfig, XmlConfig, Declaration, Version, Encoding, Indentation};
|
4
3
|
|
5
|
-
// fn hello(subject: String) -> String {
|
6
|
-
// format!("Hello from Rust, {}!", subject)
|
7
|
-
// }
|
8
|
-
|
9
4
|
#[macro_export]
|
10
5
|
macro_rules! set_arg {
|
11
|
-
($config:expr, $opts_hash:expr, $arg:ident, $arg_type:ident) =>
|
12
|
-
let arg_value = $opts_hash.
|
13
|
-
if
|
14
|
-
$config.$arg(
|
6
|
+
($config:expr, $opts_hash:expr, $arg:ident, $arg_type:ident) => {{
|
7
|
+
let arg_value: Option<Value> = $opts_hash.get(magnus::Symbol::new(stringify!($arg)));
|
8
|
+
if let Some(value) = arg_value {
|
9
|
+
$config.$arg(<$arg_type as TryConvert>::try_convert(value)?);
|
10
|
+
}
|
11
|
+
}};
|
12
|
+
}
|
13
|
+
|
14
|
+
#[macro_export]
|
15
|
+
macro_rules! get_arg {
|
16
|
+
($opts_hash:expr, $arg:ident, $arg_type:ident) => {{
|
17
|
+
let arg_value: Option<Value> = $opts_hash.get(magnus::Symbol::new(stringify!($arg)));
|
18
|
+
if let Some(value) = arg_value {
|
19
|
+
Some(<$arg_type as TryConvert>::try_convert(value)?)
|
20
|
+
} else {
|
21
|
+
None
|
15
22
|
}
|
16
|
-
|
23
|
+
}};
|
17
24
|
}
|
18
25
|
|
19
26
|
fn map_xml2json_err(error: xml2json_rs::X2JError) -> Error {
|
@@ -29,63 +36,61 @@ fn build_pretty_xml(args: &[Value]) -> Result<String, Error> {
|
|
29
36
|
}
|
30
37
|
|
31
38
|
fn build_xml_impl(args: &[Value], build_pretty: bool) -> Result<String, Error> {
|
32
|
-
let args = scan_args::<_, _, (), (),
|
39
|
+
let args = scan_args::<_, _, (), (), (), ()>(args)?;
|
33
40
|
let (json_s, ): (String, ) = args.required;
|
34
41
|
let (opts, ): (Option<magnus::RHash>, ) = args.optional;
|
35
|
-
let _: () = args.keywords;
|
36
42
|
|
37
43
|
let mut xml_builder: XmlBuilder;
|
38
|
-
if
|
44
|
+
if let Some(opts_hash) = opts { // yep, even if it's an empty hash
|
39
45
|
// println!("{}", opts.unwrap().to_string());
|
40
|
-
let opts_hash = opts.unwrap();
|
41
46
|
let mut config = XmlConfig::new();
|
42
47
|
set_arg!(config, opts_hash, root_name, String);
|
43
48
|
set_arg!(config, opts_hash, attrkey, String);
|
44
49
|
set_arg!(config, opts_hash, charkey, String);
|
45
50
|
|
46
|
-
let decl_version = opts_hash.
|
47
|
-
let decl_encoding = opts_hash.
|
48
|
-
let decl_standalone = opts_hash.
|
51
|
+
let decl_version = opts_hash.get(magnus::Symbol::new("version"));
|
52
|
+
let decl_encoding = opts_hash.get(magnus::Symbol::new("encoding"));
|
53
|
+
let decl_standalone = opts_hash.get(magnus::Symbol::new("standalone"));
|
49
54
|
if decl_version.is_some()
|
50
55
|
|| decl_encoding.is_some()
|
51
56
|
|| decl_standalone.is_some()
|
52
57
|
{ // something is specified
|
53
58
|
// I didn't find a way to get defaults without copying them
|
54
|
-
let decl_version_val
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
59
|
+
let decl_version_val = if let Some(decl_version_opt) = decl_version {
|
60
|
+
let decl_version_str = unsafe { decl_version_opt.to_s() }?.into_owned();
|
61
|
+
Version::try_from(decl_version_str.as_str())
|
62
|
+
.map_err(map_xml2json_err)?
|
63
|
+
} else { Version::XML10 };
|
64
|
+
let decl_encoding_val = if let Some(decl_encoding_opt) = decl_encoding {
|
65
|
+
let decl_encoding_str = unsafe { decl_encoding_opt.to_s() }?.into_owned();
|
66
|
+
Some(Encoding::try_from(decl_encoding_str.as_str())
|
67
|
+
.map_err(map_xml2json_err)?)
|
68
|
+
} else { None };
|
69
|
+
let decl_standalone_val = if let Some(decl_standalone_opt) = decl_standalone {
|
70
|
+
Some(TryConvert::try_convert(decl_standalone_opt)?)
|
71
|
+
} else { None };
|
66
72
|
|
67
73
|
let decl = Declaration::new(
|
68
74
|
decl_version_val,
|
69
75
|
decl_encoding_val,
|
70
|
-
|
76
|
+
decl_standalone_val,
|
71
77
|
);
|
72
78
|
config.decl(decl);
|
73
79
|
}
|
74
80
|
|
75
|
-
let indent = opts_hash
|
81
|
+
let indent = get_arg!(opts_hash, indent, bool);
|
76
82
|
if indent.unwrap_or(true) {
|
77
|
-
let
|
78
|
-
let
|
79
|
-
if
|
80
|
-
||
|
83
|
+
let indent_char_opt = get_arg!(opts_hash, indent_char, char);
|
84
|
+
let indent_size_opt = get_arg!(opts_hash, indent_size, usize);
|
85
|
+
if indent_char_opt.is_some()
|
86
|
+
|| indent_size_opt.is_some()
|
81
87
|
{
|
82
|
-
let indent_char_val: u8
|
83
|
-
|
84
|
-
|
85
|
-
} else { indent_char_val = b' '; }
|
88
|
+
let indent_char_val: u8 = if let Some(indent_char) = indent_char_opt {
|
89
|
+
u8::try_from(indent_char).map_err(|error| Error::new(magnus::exception::type_error(), error.to_string()))?
|
90
|
+
} else { b' ' };
|
86
91
|
config.rendering(Indentation::new(
|
87
92
|
indent_char_val,
|
88
|
-
|
93
|
+
indent_size_opt.unwrap_or(2),
|
89
94
|
));
|
90
95
|
} else if indent.unwrap_or(build_pretty) {
|
91
96
|
// because Indentation::default is not the same as not calling config.rendering at all;
|
@@ -97,8 +102,8 @@ fn build_xml_impl(args: &[Value], build_pretty: bool) -> Result<String, Error> {
|
|
97
102
|
xml_builder = XmlConfig::new().rendering(Indentation::default()).finalize();
|
98
103
|
} else { xml_builder = XmlBuilder::default(); }
|
99
104
|
|
100
|
-
xml_builder.build_from_json_string(&json_s).
|
101
|
-
|
105
|
+
xml_builder.build_from_json_string(&json_s).map_err(|error| {
|
106
|
+
map_xml2json_err(error)
|
102
107
|
})
|
103
108
|
}
|
104
109
|
|
@@ -112,70 +117,12 @@ fn build_pretty_json(args: &[Value]) -> Result<String, Error> {
|
|
112
117
|
|
113
118
|
fn build_json_impl(args: &[Value], mut build_pretty: bool) -> Result<String, Error> {
|
114
119
|
// https://docs.rs/magnus/latest/magnus/scan_args/fn.scan_args.html
|
115
|
-
let args = scan_args::<_, _, (), (),
|
120
|
+
let args = scan_args::<_, _, (), (), (), ()>(args)?;
|
116
121
|
let (xml, ): (String, ) = args.required;
|
117
122
|
let (opts, ): (Option<magnus::RHash>, ) = args.optional;
|
118
|
-
// let _: () = args.optional;
|
119
|
-
let _: () = args.keywords;
|
120
|
-
|
121
|
-
// Impossible, too long
|
122
|
-
// let kw = get_kwargs::<_, (), (
|
123
|
-
// Option<String>, // charkey
|
124
|
-
// Option<String>, // attrkey
|
125
|
-
// Option<String>, // empty_tag
|
126
|
-
// Option<bool>, // explicit_root
|
127
|
-
// Option<bool>, // trim
|
128
|
-
// Option<bool>, // ignore_attrs
|
129
|
-
// Option<bool>, // merge_attrs
|
130
|
-
// Option<bool>, // normalize_text
|
131
|
-
// Option<bool>, // lowercase_tags
|
132
|
-
// Option<bool>, // explicit_array
|
133
|
-
// Option<bool>, // explicit_charkey
|
134
|
-
// ), ()>(args.keywords, &[], &[
|
135
|
-
// "charkey",
|
136
|
-
// "attrkey",
|
137
|
-
// "empty_tag",
|
138
|
-
// "explicit_root",
|
139
|
-
// "trim",
|
140
|
-
// "ignore_attrs",
|
141
|
-
// "merge_attrs",
|
142
|
-
// "normalize_text",
|
143
|
-
// "lowercase_tags",
|
144
|
-
// "explicit_array",
|
145
|
-
// "explicit_charkey",
|
146
|
-
// ])?;
|
147
|
-
// let (
|
148
|
-
// charkey,
|
149
|
-
// attrkey,
|
150
|
-
// empty_tag,
|
151
|
-
// explicit_root,
|
152
|
-
// trim,
|
153
|
-
// ignore_attrs,
|
154
|
-
// merge_attrs,
|
155
|
-
// normalize_text,
|
156
|
-
// lowercase_tags,
|
157
|
-
// explicit_array,
|
158
|
-
// explicit_charkey,
|
159
|
-
// ) = kw.optional;
|
160
|
-
// if charkey.is_some()
|
161
|
-
// || attrkey.is_some()
|
162
|
-
// || empty_tag.is_some()
|
163
|
-
// || explicit_root.is_some()
|
164
|
-
// || trim.is_some()
|
165
|
-
// || ignore_attrs.is_some()
|
166
|
-
// || merge_attrs.is_some()
|
167
|
-
// || normalize_text.is_some()
|
168
|
-
// || lowercase_tags.is_some()
|
169
|
-
// || explicit_array.is_some()
|
170
|
-
// || explicit_charkey.is_some()
|
171
|
-
// {
|
172
|
-
// println!("any")
|
173
|
-
// } else { println!("none") }
|
174
123
|
|
175
124
|
let json_builder: JsonBuilder;
|
176
|
-
if
|
177
|
-
// println!("{}", opts.unwrap().to_string());
|
178
|
-
let opts_hash = opts.unwrap();
|
125
|
+
if let Some(opts_hash) = opts { // yep, even if it's an empty hash
|
179
126
|
let mut config = JsonConfig::new();
|
180
127
|
set_arg!(config, opts_hash, charkey, String);
|
181
128
|
set_arg!(config, opts_hash, attrkey, String);
|
@@ -190,9 +137,8 @@ fn build_json_impl(args: &[Value], mut build_pretty: bool) -> Result<String, Err
|
|
190
137
|
set_arg!(config, opts_hash, explicit_charkey, bool);
|
191
138
|
json_builder = config.finalize();
|
192
139
|
|
193
|
-
let indent = opts_hash
|
194
|
-
|
195
|
-
build_pretty = indent.unwrap();
|
140
|
+
if let Some(indent) = get_arg!(opts_hash, indent, bool) {
|
141
|
+
build_pretty = indent;
|
196
142
|
}
|
197
143
|
} else { json_builder = JsonBuilder::default(); }
|
198
144
|
|
@@ -200,16 +146,14 @@ fn build_json_impl(args: &[Value], mut build_pretty: bool) -> Result<String, Err
|
|
200
146
|
json_builder.build_pretty_string_from_xml(&xml)
|
201
147
|
} else {
|
202
148
|
json_builder.build_string_from_xml(&xml)
|
203
|
-
}.
|
204
|
-
|
149
|
+
}.map_err(|error| {
|
150
|
+
map_xml2json_err(error)
|
205
151
|
})
|
206
152
|
}
|
207
153
|
|
208
154
|
#[magnus::init]
|
209
155
|
fn init() -> Result<(), Error> {
|
210
156
|
let module = define_module("Xml2Json")?;
|
211
|
-
// module.define_singleton_method("hello", function!(hello, 1))?;
|
212
|
-
// It's not possible to wrap XmlBuilder
|
213
157
|
let xml = module.define_module("Xml")?;
|
214
158
|
let xml_version = xml.define_module("Version")?;
|
215
159
|
xml_version.const_set("XML10", Version::XML10.to_string())?;
|
data/lib/xml2json/version.rb
CHANGED
data/lib/xml2json.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "xml2json/version"
|
4
|
-
|
4
|
+
begin
|
5
|
+
require_relative "xml2json/#{RUBY_VERSION[/(\d+\.\d+)/, 1]}/xml2json"
|
6
|
+
rescue LoadError
|
7
|
+
require_relative "xml2json/xml2json"
|
8
|
+
end
|
5
9
|
|
6
|
-
# @see https://
|
10
|
+
# @see https://docs.rs/xml2json-rs/1.0.1/xml2json_rs/index.html docs for the wrapped library
|
7
11
|
module Xml2Json
|
8
12
|
# @!parse [ruby]
|
9
13
|
# module Xml
|
@@ -17,20 +21,66 @@ module Xml2Json
|
|
17
21
|
#
|
18
22
|
# # @param json_s [String, #to_str] JSON string
|
19
23
|
# # @param opts [Hash<Symbol, Object>] config params
|
20
|
-
# # @
|
24
|
+
# # @note Default values are provided by xml2json-rs
|
25
|
+
# # @see https://docs.rs/xml2json-rs/1.0.1/xml2json_rs/struct.XmlConfig.html Docs for xml2json-rs XmlConfig
|
26
|
+
# # @option opts [String, #to_str] root_name ("root") Root key name to contain produced JSON object
|
27
|
+
# # @option opts [String, #to_str] attrkey ("$") The value of the JSON key used to store XML attributes under
|
28
|
+
# # @option opts [String, #to_str] charkey ("_") The value of the JSON key used to store XML character data under
|
29
|
+
# # @option opts [nil, "1.0", "1.1", #to_s] version (Xml2Json::Version::XML10) XML Declaration 'version' field,
|
30
|
+
# # default if nil
|
31
|
+
# # @raise [RuntimeError] if +version.to_s+ returns unsupported string,
|
32
|
+
# # for now only +"1.0"+ and +"1.1"+ are supported
|
33
|
+
# # @option opts [nil, "UTF-8", #to_s] encoding (nil) XML Declaration 'encoding' field, empty if nil
|
34
|
+
# # @raise [RuntimeError] if +encoding.to_s+ returns unsupported string, for now only +"UTF-8"+ is supported
|
35
|
+
# # @option opts [bool, nil] standalone (nil) XML Declaration 'standalone' field, empty if nil
|
36
|
+
# # @option opts [bool] indent (false) Output XML with line-breaks and indentations
|
37
|
+
# # @option opts [String, #to_str] indent_char (" ") Character used for indentation. This option will be ignored
|
38
|
+
# # if +indent+ is false
|
39
|
+
# # @raise [TypeError] If +indent_char+ is more than one character or can not be encoded as UTF-8
|
40
|
+
# # @note It's not enough for the Ruby +indent_char+ string to be UTF-8 encoded, not sure
|
41
|
+
# # if that's a bug or a feature of Magnus
|
42
|
+
# # @option opts [Integer, #to_int] indent_size (2) Number of characters used for indentation.
|
43
|
+
# # This option will be ignored if +indent+ is false
|
44
|
+
# # @raise [RangeError] if +indent_size+ cannot be converted into +unsigned long long+
|
21
45
|
# # @return [String] XML string
|
22
|
-
# # @raise [RuntimeError] if
|
46
|
+
# # @raise [RuntimeError] if +json_s+ is not valid JSON
|
47
|
+
# # @raise [TypeError] if +opts+ contain invalid value
|
23
48
|
# def self.build(json_s, opts: nil); end
|
49
|
+
# # @option opts [bool] indent (true)
|
50
|
+
# # @note Check +Xml2Json::Xml.build+ for other details, the only difference is that +indent+ is true by default
|
51
|
+
# # @see .build
|
24
52
|
# def self.build_pretty(json_s, opts: nil); end
|
25
53
|
# end
|
26
54
|
#
|
27
55
|
# module Json
|
28
56
|
# # @param xml [String, #to_str] XML string
|
29
57
|
# # @param opts [Hash<Symbol, Object>] config params
|
30
|
-
# # @
|
58
|
+
# # @note Default values are provided by xml2json-rs
|
59
|
+
# # @see https://docs.rs/xml2json-rs/1.0.1/xml2json_rs/struct.JsonConfig.html Docs for xml2json-rs JsonConfig
|
60
|
+
# # @option opts [String, #to_str] attrkey ("$") Key to outer object containing tag attributes
|
61
|
+
# # @option opts [String, #to_str] charkey ("_") Key to store character content under
|
62
|
+
# # @option opts [String, #to_str] empty_tag ("") The value of empty nodes
|
63
|
+
# # @option opts [bool] indent (false) Output JSON with line-breaks and indentations
|
64
|
+
# # @option opts [bool] explicit_root (true) Sets the root node inside the resulting object
|
65
|
+
# # @option opts [bool] trim (false) Trim whitespace at the beginning and end of text nodes
|
66
|
+
# # @option opts [bool] ignore_attrs (false) Setting this to true will skip adding element attributes
|
67
|
+
# # and create text nodes
|
68
|
+
# # @option opts [bool] merge_attrs (false) Merge all XML attributes and child elements as properties of
|
69
|
+
# # the parent, instead of keying attributes off of the child attribute object. This option will be
|
70
|
+
# # ignored if +ignore_attrs+ is true
|
71
|
+
# # @option opts [bool] normalize_text (false) Removes whitespace character data in text nodes
|
72
|
+
# # @option opts [bool] lowercase_tags (false) Normalize all tags by converting them to lowercase
|
73
|
+
# # @option opts [bool] explicit_array (true) Always put the child nodes in an array, otherwise an array is only
|
74
|
+
# # created if there is more than one child
|
75
|
+
# # @option opts [bool] explicit_charkey (false) Always store character data under +charkey+ even if there are
|
76
|
+
# # no other text elements stored inside the tag
|
31
77
|
# # @return [String] JSON string
|
32
|
-
# # @raise [RuntimeError] if
|
78
|
+
# # @raise [RuntimeError] if +xml+ is not valid XML
|
79
|
+
# # @raise [TypeError] if +opts+ contain invalid value
|
33
80
|
# def self.build(xml, opts: nil); end
|
81
|
+
# # @option opts [bool] indent (true)
|
82
|
+
# # @note Check +Xml2Json::Json.build+ for other details, the only difference is that +indent+ is true by default
|
83
|
+
# # @see .build
|
34
84
|
# def self.build_pretty(xml, opts: nil); end
|
35
85
|
# end
|
36
86
|
end
|
metadata
CHANGED
@@ -1,15 +1,197 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xml2json-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- uvlad7
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
11
|
+
date: 2025-04-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '13.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '13.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake-compiler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rb_sys
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.9.63
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.9.63
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.21'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.21'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: base64
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry-byebug
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: yard
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rack
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rackup
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: puma
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: toml-rb
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
13
195
|
description: This gem helps to convert xml strings to json and vise versa
|
14
196
|
email:
|
15
197
|
- uvlad7@gmail.com
|
@@ -25,7 +207,6 @@ files:
|
|
25
207
|
- ext/xml2json/src/lib.rs
|
26
208
|
- lib/xml2json.rb
|
27
209
|
- lib/xml2json/version.rb
|
28
|
-
- lib/xml2json/xml2json.so
|
29
210
|
- sig/xml2_json/json.rbs
|
30
211
|
- sig/xml2_json/xml.rbs
|
31
212
|
- sig/xml2_json/xml/encoding.rbs
|
@@ -38,9 +219,9 @@ metadata:
|
|
38
219
|
homepage_uri: https://github.com/uvlad7/xml2json-rb
|
39
220
|
source_code_uri: https://github.com/uvlad7/xml2json-rb
|
40
221
|
changelog_uri: https://github.com/uvlad7/xml2json-rb/blob/main/CHANGELOG.md
|
41
|
-
documentation_uri: https://rubydoc.info/gems/xml2json-rb/0.3.
|
222
|
+
documentation_uri: https://rubydoc.info/gems/xml2json-rb/0.3.2
|
42
223
|
rubygems_mfa_required: 'true'
|
43
|
-
post_install_message:
|
224
|
+
post_install_message:
|
44
225
|
rdoc_options: []
|
45
226
|
require_paths:
|
46
227
|
- lib
|
@@ -55,8 +236,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
55
236
|
- !ruby/object:Gem::Version
|
56
237
|
version: 3.3.11
|
57
238
|
requirements: []
|
58
|
-
rubygems_version: 3.4.
|
59
|
-
signing_key:
|
239
|
+
rubygems_version: 3.4.14
|
240
|
+
signing_key:
|
60
241
|
specification_version: 4
|
61
242
|
summary: Ruby wrapper for xml2json-rs
|
62
243
|
test_files: []
|
data/lib/xml2json/xml2json.so
DELETED
Binary file
|