From 38392562e14f8811ab845d1ea3658b6cc2932c76 Mon Sep 17 00:00:00 2001 From: gwarser Date: Thu, 11 Apr 2024 14:06:39 +0200 Subject: [PATCH] JSON.prune new properties: [-], {-} --- Resources-Library.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Resources-Library.md b/Resources-Library.md index ce9427c..7321c85 100644 --- a/Resources-Library.md +++ b/Resources-Library.md @@ -382,7 +382,7 @@ A property in a list of properties can be a chain of properties, example: `adpat After [1.28.0](https://github.com/gorhill/uBlock/commit/f433932d8602230539d3408e9946d4d70b40306c), two special _"wildcard tokens"_ have been added: -- `[]` - will iterate in all elements in an array. To deal with cases where the +- `[]`: iterate in all elements in an array. To deal with cases where the property to remove is an element in an array. To remove `adserver` object properties from array in following JSON payload: @@ -392,7 +392,7 @@ property to remove is an element in an array. +js(json-prune, playlist.[].adserver) -- `*` - will iterate through all own properties of an object. For example, to deal with hard to predict random-named properties. +- `*`: will iterate through all own properties of an object. For example, to deal with hard to predict random-named properties. To remove `adserver` object properties from inside _randomly named_ objects in following JSON payload: {"playlist": {"random1": {"adserver": "first"}, "randomB": {"adserver": "second"}}} @@ -401,6 +401,12 @@ property to remove is an element in an array. +js(json-prune, playlist.*.adserver) +Version [1.57.0](https://github.com/gorhill/uBlock/commit/e7a0f8c7810c002bc7cec6a1160f8b091f8ea52e) extend syntax with two special token properties: +- `[-]`: remove an array entry if part right of `[-]` matches the + inspected item. +- `{-}`: remove a property if part right of `{-}` mmatches the + inspected item. + When used without parameters, will log current hostname + json payload to the console. New in [1.27.0](https://github.com/gorhill/uBlock/commit/578594bbd7c545b62f18267d640a605f8e07a53a) - second parameter can be used to limit logging to JSON payloads which stringified content match specified string or _regular expression_.