Skip to navigation
Decode a string like binary to String in rust
20.09.22
To decode allowing arbitrary bytes and invalid UTF-8: use urlencoding::decode_binary; let binary = decode_binary(b"%F1%F2%F3%C0%C1%C2"); let decoded = String::from_utf8_lossy(&binary); let s = res.unwrap().body().await.unwrap(); let d = String::from_utf8_lossy(&s); let mut dj = json::parse(&file).unwrap(); dj["expires_at"] = dj["expires_in"].to_string().into(); println!("{}",dj["access_token"]); let jtoken = dj.dump(); fs::write("src/token2.json", jtoken).await;
https://docs.rs/urlencoding/latest/urlencoding/
Reply
Anonymous
let _bin = _res.unwrap().body().await.unwrap(); let _s = String::from_utf8_lossy(&_bin); println!("{:?}",_s); let mut _dj = json::parse(&_s).unwrap(); println!("{:?}",_dj); println!("Current Seconds: {}", time); let x = _dj["expires_in"].as_u64().unwrap() + time; _dj["expires_at"] = x.to_string().into(); println!("{}",_dj["access_token"]); let _jtoken = _dj.dump(); fs::write("src/token.json", _jtoken).await;
20.09.22
Reply
Anonymous
Information Epoch 1732476729
Allow the user to tailor the environment.
Home
Notebook
Contact us