Skip to content

Commit

Permalink
pretty print json_strings coming back from jetstream
Browse files Browse the repository at this point in the history
  • Loading branch information
damiensedgwick committed Nov 14, 2024
1 parent 374ec88 commit 6fbe9f9
Show file tree
Hide file tree
Showing 3 changed files with 188 additions and 2 deletions.
182 changes: 182 additions & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions packages-rs/drainpipe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ version = "0.2.0"
edition = "2021"

[dependencies]
chrono = { version = "0.4.38", features = ["serde"] }
futures-util = "0.3"
serde = "1.0.203"
serde_json = { version = "1.0" }
tokio = { version = "1.38.0", features = ["full"] }
tokio-metrics = "0.3.1"
tokio-tungstenite = { version = "0.23.0", features = ["native-tls"] }
5 changes: 3 additions & 2 deletions packages-rs/drainpipe/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ async fn main() -> Result<(), Box<dyn Error>> {

while let Some(msg) = stream.next().await {
match msg {
Ok(Message::Text(text)) => {
println!("{}", text);
Ok(Message::Text(json_string)) => {
let json: serde_json::Value = serde_json::from_str(&json_string).unwrap();
println!("{}", serde_json::to_string_pretty(&json).unwrap());
}
Err(e) => {
eprintln!("Error: {}", e);
Expand Down

0 comments on commit 6fbe9f9

Please sign in to comment.