Skip to content

Commit

Permalink
Added to_json method to pyauditor Record
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-k committed Feb 23, 2023
1 parent e9790cc commit 5c78dbe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions pyauditor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ pyo3-asyncio = { version = "0.15", features = ["attributes", "tokio-runtime"] }
tokio = "1"
chrono = { version = "0.4.22", features = ["serde"] }
pyo3-chrono = { version = "0.3.0", features = [] }
serde_json = "1.0.93"
5 changes: 5 additions & 0 deletions pyauditor/src/domain/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ impl Record {
fn runtime(&self) -> Option<i64> {
self.inner.runtime
}

/// Output content of Record as JSON-encoded string
fn to_json(&self) -> Result<String, Error> {
Ok(format!("{}", serde_json::to_value(&self.inner)?))
}
}

#[pyproto]
Expand Down

0 comments on commit 5c78dbe

Please sign in to comment.