pub fn selective_digest(
data: &JsValue,
keep_properties_list: &str,
) -> Result<String, JsValue>
Expand description
Returns a canonical string representation of a JSON document, in which any sub-objects not explicitly listed in the second argument are collapsed to their digest. The format of the second argument is inspired by JQ basic filters and these are some examples:
{
"a": {
"1": "apple",
"2": "banana"
},
"b": ["some", "array", 0xf, "values"],
"c": 42
}
- “” -> Same as calling {@link digestJson}
- “.a” -> Keep property “a” untouched, the rest will be replaced with their digest. Note that most likely the scalar number “c” does not have enough entropy to avoid a brute-force attack for its digest.
- “.b, .c” -> Keeps both properties “b” and “c” unaltered, but “a” will be replaced with the digest of that sub-object.
You should protect scalar values and easy-to-guess lists by replacing them with an object that has an extra “nonce” property, which has enough entropy. @see wrapJsonWithNonce