]>
git.proxmox.com Git - proxmox.git/blob - proxmox-acme/src/json.rs
1 use openssl
::hash
::Hasher
;
6 pub fn to_hash_canonical(value
: &Value
, output
: &mut Hasher
) -> Result
<(), Error
> {
8 Value
::Null
| Value
::String(_
) | Value
::Number(_
) | Value
::Bool(_
) => {
9 serde_json
::to_writer(output
, &value
)?
;
11 Value
::Array(list
) => {
13 let mut iter
= list
.iter();
14 if let Some(item
) = iter
.next() {
15 to_hash_canonical(item
, output
)?
;
18 to_hash_canonical(item
, output
)?
;
23 Value
::Object(map
) => {
25 let mut keys
: Vec
<&str> = map
.keys().map(String
::as_str
).collect();
27 let mut iter
= keys
.into_iter();
28 if let Some(key
) = iter
.next() {
29 serde_json
::to_writer(&mut *output
, &key
)?
;
31 to_hash_canonical(&map
[key
], output
)?
;
34 serde_json
::to_writer(&mut *output
, &key
)?
;
36 to_hash_canonical(&map
[key
], output
)?
;