aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorValentin Popov <info@valentineus.link>2019-01-27 16:39:10 +0300
committerValentin Popov <info@valentineus.link>2019-01-27 16:39:10 +0300
commita0694a3418534cc6e74e7b269327893fda5b57e9 (patch)
tree4e968e22cc0ee2bfd9783dfe51ea0643700b75ef /src
parentf7f2ce8e5bbe55a6a960dd8ccf521a1a0a7b6fb0 (diff)
downloadbbb2json-a0694a3418534cc6e74e7b269327893fda5b57e9.tar.xz
bbb2json-a0694a3418534cc6e74e7b269327893fda5b57e9.zip
Sun, 27 Jan 2019 17:39:10 +0400
Signed-off-by: Valentin Popov <info@valentineus.link>
Diffstat (limited to 'src')
-rw-r--r--src/parser.rs35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/parser.rs b/src/parser.rs
index 0b477ce..2a2c2cf 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -1,6 +1,7 @@
use std::fs::File;
use std::io::BufReader;
+use serde_json::Value;
use xml::reader::{EventReader, XmlEvent};
#[derive(Serialize)]
@@ -8,10 +9,12 @@ pub struct ParserResult {
pub external_id: String,
pub meeting_id: String,
pub meeting_name: String,
+ pub context: Value,
}
pub fn parser(content: BufReader<File>) -> ParserResult {
let mut data = ParserResult {
+ context: serde_json::from_str("{}").unwrap(),
external_id: "".to_string(),
meeting_id: "".to_string(),
meeting_name: "".to_string(),
@@ -20,20 +23,28 @@ pub fn parser(content: BufReader<File>) -> ParserResult {
for element in EventReader::new(content) {
match element {
Ok(XmlEvent::StartElement {
- name: _,
- attributes,
- ..
+ name, attributes, ..
}) => {
+ let el_name = name.local_name.to_string();
+
for attribute in attributes {
- let name: String = attribute.name.local_name.to_string();
- let value: String = attribute.value.to_string();
-
- if name == "externalId" {
- data.external_id = value;
- } else if name == "meetingId" {
- data.meeting_id = value;
- } else if name == "meetingName" {
- data.meeting_name = value;
+ let attr_name: String = attribute.name.local_name.to_string();
+ let attr_value: String = attribute.value.to_string();
+
+ if el_name == "meeting" && attr_name == "id" {
+ data.meeting_id = attr_value.clone();
+ }
+
+ if el_name == "meeting" && attr_name == "externalId" {
+ data.external_id = attr_value.clone();
+ }
+
+ if el_name == "meeting" && attr_name == "name" {
+ data.meeting_name = attr_value.clone();
+ }
+
+ if el_name == "metadata" && attr_name == "bn-recording-status" {
+ data.context = serde_json::from_str(&attr_value).unwrap();
}
}
}