Note
It skipped 0.4.0 version for tests. π 0.5.0 is the next version of 0.3.1
Full Changelog: 0.3.1...0.5.0
Support Bencodex JSON
Since 0.5.0, it provides Bencodex JSON-related features. You can enable the feature with json
feature flag. Then you can use the functions like bencodex::json::from_json_string
, bencodex::json::to_json
.
use bencodex::{ BencodexValue, json::to_json };
let json = to_json(&BencodexValue::Null);
println!("{}", json);
// from_json_string
use bencodex::{ BencodexValue, json::from_json_string };
let result = from_json_string("null");
assert!(result.is_ok());
assert_eq!(result.unwrap(), BencodexValue::Null);
Support Bencodex JSON CLI tool
It started to provide CLI tool to encode and decode between Bencodex and JSON.
# encode
$ echo -n 'n' | bencodex
null
$ echo -n 'i123e' | bencodex
"123"
$ echo -n '1:\x12' | bencodex
"0x12"
$ echo -n '1:\x12' | bencodex --base64
"b64:Eg=="
# decode
$ echo -n '"123"' | bencodex -d
123
$ echo -n 'null' | bencodex -d
n