Skip to content

Syntax for removing elements from JSON responses #1447

@ameshkov

Description

@ameshkov

We often face issues when we need to modify JSON strings. Usually, we use $replace for that, but it is FAR from ideal.

What we really need is a new modifier similar to $replace that will work with JSON's specifically.

Now, the question is what syntax should we use that can be understood and can be tested/debugged as easy as a regular expression.

I suggest using jq syntax for that: https://stedolan.github.io/jq/

Here's why:

  1. jq is written in C under a permissive license and we can use it as a library: https://github.com/stedolan/jq/blob/master/COPYING
  2. jq can be used in conjunction with curl to test the jq expressions: https://stedolan.github.io/jq/tutorial/
  3. jq expressions can also be tested online: https://jqplay.org/

@sfionov @sxgunchenko any ideas on what syntax of this modifier could be?
@AdguardTeam/filters-maintainers what do you think about this idea?

edit: relevant: AdguardTeam/Scriptlets#183 (comment)

Maybe using jq is not that sane, we'd better find something that has implementations in both JS and C/C++

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions