Skip to content

Commit

Permalink
Replace json with serde_json dependency for nats_server
Browse files Browse the repository at this point in the history
  • Loading branch information
nepalez committed Sep 16, 2023
1 parent 76db373 commit e5428ac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion nats-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ license = "Apache-2.0"
lazy_static = "1.4.0"
regex = { version = "1.7.1", default-features = false, features = ["std", "unicode-perl"] }
url = "2"
json = "0.12"
serde_json = "1.0.104"
nuid = "0.5"
rand = "0.8"
tokio-retry = "0.3.0"
Expand Down
9 changes: 5 additions & 4 deletions nats-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use std::{thread, time::Duration};
use lazy_static::lazy_static;
use rand::Rng;
use regex::Regex;
use serde_json::{self, Value};

pub struct Server {
inner: Inner,
Expand Down Expand Up @@ -77,8 +78,8 @@ impl Server {
let mut r = BufReader::with_capacity(1024, TcpStream::connect(addr).unwrap());
let mut line = String::new();
r.read_line(&mut line).expect("did not receive INFO");
let si = json::parse(&line["INFO".len()..]).unwrap();
let port = si["port"].as_u16().expect("could not parse port");
let si: Value = serde_json::from_str(&line["INFO".len()..]).expect("could not parse INFO");
let port = si["port"].as_u64().expect("could not parse port") as u16;
let mut scheme = "nats://";
if si["tls_required"].as_bool().unwrap_or(false) {
scheme = "tls://";
Expand All @@ -91,8 +92,8 @@ impl Server {
let mut r = BufReader::with_capacity(1024, TcpStream::connect(addr).unwrap());
let mut line = String::new();
r.read_line(&mut line).expect("did not receive INFO");
let si = json::parse(&line["INFO".len()..]).unwrap();
si["port"].as_u16().expect("could not parse port")
let si: Value = serde_json::from_str(&line["INFO".len()..]).expect("could not parse INFO");
si["port"].as_u64().expect("could not parse port") as u16
}

// Allow user/pass override.
Expand Down

0 comments on commit e5428ac

Please sign in to comment.