summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* jsonfilter: drop legacy json-c supportHEADmasterSergey Ponomarev2022-06-291-3/+2
| | | | | | | | | | | | | | | The cmake logic is wrong (E.G. PKG_CHECK_FOR_MODULES fails unless all modules are found), and the legacy libjson.so name is also used by the other libjson (for example [1]) which provides an incompatible API, so just drop it. Backported from libubox cbf80de7f4df61960f386cb01a899cf4228d38f3 [1] http://sourceforge.net/projects/libjson/ Signed-off-by: Sergey Ponomarev <stokito@gmail.com> [ wrapped commit description to 75 char limit ] Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
* implement POSIX regexp supportJo-Philipp Wich2018-02-045-4/+176
| | | | | | | | | | | | | | | | | | | | | | | | | Introduce a new operator `~` and new `/.../eis` regular expression syntax. This allows filtering by regular expression, e.g. jsonfilter -s '[ "foo", "bar", "baz" ]' -e '$[@ ~ /^b/]' ... would yield the values `bar` and `baz`. Possible regular expression modifiers are: - `e` ... enable extended POSIX regular expressions - `i` ... perform case insensitive matches - `s` ... let ranges and `.` match the newline character A regular expression literal may occur on the left or the right side of the `~` operator, but not on both. In case neither side of the `~` operator is a regular expression, the right side will be treated as regular expression pattern. Non-string values are converted to their string representation before performing matching. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* lexer: fix encoding 7 bit escape sequencesJo-Philipp Wich2018-02-041-1/+1
| | | | | | | | A misplaced paren caused escape sequences in the ranges \x00..\x7f, \u0000..\u007f and \0..\177 to get improperly encoded into the string buffer. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* main: implement array modeJo-Philipp Wich2018-02-041-12/+68
| | | | | | | | | | | Implement a new option "-a" which turns on array mode, meaning that the program will attempt to parse multiple consecutive JSON objects from the source data and merge them into a JSON array. This is mainly useful for operating on JSON log files with one object per line. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* remove obsolete /opt/local include/lib directories on mac os xFelix Fietkau2016-07-021-5/+0
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* remove --gc-sections for mac os x buildsFelix Fietkau2016-07-021-1/+3
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* cmake: Find libubox/list.h header fileFlorian Fainelli2016-07-021-0/+3
| | | | | | | | Add a CMake FIND_PATH and INCLUDE_DIRECTORIES searching for libubox/list.h. Some external toolchains which do not include standard locations would fail to find the header otherwise. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
* treewide: replace jow@openwrt.org with jo@mein.ioJo-Philipp Wich2016-06-078-8/+8
| | | | Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* cli: properly format 64bit valuesJo-Philipp Wich2016-06-011-1/+2
| | | | Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* parser: allow root path specificationsJo-Philipp Wich2016-05-241-0/+2
| | | | | | | | | | | | All a patch specification to be just '@' or '$' - this is mainly useful when exporting the keys of the toplevel object to the shell. Example: $ echo '{ "abc": 1, "def": 2 }' | jsonpath -e 'keys=@' export keys='abc'\ 'def'; Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* main: Add basic help outputKarl Palsson2016-02-031-1/+47
| | | | | | | | Add basic usage text to the binary and print it when invoked with -h or with no arguments at all. Signed-off-by: Karl Palsson <karlp@remake.is> Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
* matcher: fix segfault with subscript on non-array elementJo-Philipp Wich2016-02-031-7/+10
| | | | Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
* contrib: add ParseTrace prototype to parser skeletonJo-Philipp Wich2016-02-031-0/+1
| | | | Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
* cli: prevent segfault if input file failed to openJo-Philipp Wich2015-10-271-1/+1
| | | | Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
* cli: implement limit flagJo-Philipp Wich2014-06-191-8/+23
| | | | | | | | The new "-l" flag allows limiting the number of results getting printed. This is useful for expressions which match many items when only the first is desired. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
* matcher.c: properly handle negative array indizesJo-Philipp Wich2014-06-191-2/+9
| | | | Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
* cli: add a flag to specify arbritary field separatorsJo-Philipp Wich2014-06-191-26/+46
| | | | | | | This is useful to join values with a specified char instead of the default space. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
* Improve error reportingJo-Philipp Wich2014-06-185-53/+116
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Keep track of the exact location the error occured in and switch the internal error description from a dynamic string buffer to an integer which either holds negative values for lexer errors or positives values for grammer violations. In case of grammer violations the "error_code" member will hold a bitfield describing the expected tokens. Also rework the error messages emitted by the cli to be more precise. Examples: $ jsonfilter -s '{}' -e '@.foo bar' Syntax error: Expecting End of file In expression @.foo bar Near here ----------^ $ jsonfilter -s '{}' -e '@.foo\bar' Syntax error: Unexpected character In expression @.foo\bar Near here ---------^ $ jsonfilter -s '{}' -e '@.foo..bar' Syntax error: Expecting Label or '*' In expression @.foo..bar Near here ----------^ Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
* cli: minor whitespace fixJo-Philipp Wich2014-06-181-1/+1
| | | | Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
* Switch to sqlite3's lemon parser generator.Jo-Philipp Wich2014-06-1513-426/+6619
| | | | | | | | | | | This commit drops the flex + bison code in favor to a hand-written lexer and a new grammar file in lemon syntax. The change results in a much smaller binary and easier to maintain code. Code required to build and maintain the AST has been split off into the ast.c and ast.h files. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
* build: use -ffunction-sections and --gc-sectionsJo-Philipp Wich2014-06-131-2/+2
| | | | Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
* cli: supress printing "null" in non-export mode, output strings unescapedJo-Philipp Wich2014-01-061-1/+19
|
* Update copyrightJo-Philipp Wich2014-01-025-5/+5
|
* parser: fix error reportingJo-Philipp Wich2014-01-011-2/+5
|
* lexer, parser, matcher: extend grammar to allow comma separated keys/indexes ↵Jo-Philipp Wich2014-01-013-3/+15
| | | | as more readable alternative to or expressions
* cli: gather all found items through a callback functionJo-Philipp Wich2014-01-011-58/+117
|
* matcher: add user callback and support implicit index/key comparesJo-Philipp Wich2014-01-012-24/+40
| | | | | - introduced callback argument in jp_match() which is invoked for each found json item - when chaining strings or numbers in or expressions, implicitely match them against the current key
* lexer: accept single quoted string literalsJo-Philipp Wich2013-12-312-6/+13
|
* parser: fix order of declarationsJo-Philipp Wich2013-12-291-1/+1
|
* cli: implemnt -s flag to pass json source as string argumentJo-Philipp Wich2013-12-291-8/+20
|
* cli: additional flags and cleanupJo-Philipp Wich2013-12-291-59/+113
| | | | | | | | | | | * add -q flag to suppress error messages * add -t flag to test type of result * clean up exit codes to indicate success; - 0 if all -t and -e expression yielded a result - 1 if at least one -t or -e expression didn't match - 125 when failed to open input file - 126 when failed to parse json input - 127 when the farser fails due to oom
* parser: change exitcode in case of oom errorsJo-Philipp Wich2013-12-291-1/+1
|
* Amend gitignoreJo-Philipp Wich2013-12-291-0/+2
|
* Add gitignore fileJo-Philipp Wich2013-12-291-0/+6
|
* eliminate global variables and use a private parser/lexer stateJo-Philipp Wich2013-12-293-84/+105
|
* cmake: let generated lexer.c, parser.c depend on their respective source ↵Jo-Philipp Wich2013-12-291-0/+4
| | | | files, clean generated headers
* Remove generated filesJo-Philipp Wich2013-12-282-452/+0
|
* Initial commitJo-Philipp Wich2013-12-288-0/+1418