rsyslog / liblognorm

a fast samples-based log normalization library
http://www.liblognorm.com
GNU Lesser General Public License v2.1
99 stars 64 forks source link

Add a parameter skipempty to the json field type. #305

Open nhosoi opened 6 years ago

nhosoi commented 6 years ago

If skipempty is set as follows, empty json objects are dropped from the parsed result. %field_name:json:skipempty%

If any parameter other than "skipempty" is given ("bogus" in this example), an error message "invalid flag for JSON parser: bogus" is issued.

Add test for the skipempty parameter.

richm commented 6 years ago

Dependency on libfastjson needs to be updated to 0.99.8 or later to pick up https://github.com/rsyslog/libfastjson/pull/155

[2018-07-27 18:33:32] [build] parser.c:2365:5: warning: implicit declaration of function ‘json_object_array_del_idx’; did you mean ‘json_object_array_get_idx’? [-Wimplicit-function-declaration]
[2018-07-27 18:33:32] [build]      json_object_array_del_idx(json, i--);
[2018-07-27 18:33:32] [build]      ^~~~~~~~~~~~~~~~~~~~~~~~~
[2018-07-27 18:33:32] [build]      json_object_array_get_idx
...
[2018-07-27 18:33:39] [build]   CCLD     lognormalizer
[2018-07-27 18:33:40] [build] ../src/.libs/liblognorm.so: undefined reference to `json_object_array_del_idx'
nhosoi commented 5 years ago

@rgerhards, sorry about this slow post.

I double-checked libfastjson and learned https://github.com/rsyslog/libfastjson/pull/155 is merged to the master branch, but it's not in the tagged release. The latest libfastjson version is v0.99.8 which was released on Dec 18 2017 and 9 commits were merged to the master branch since then. pr/155 is one of them. Thus, this pr fails the tests even with the libfastjson v0.99.8... :( It requires new version of libfastjson including https://github.com/rsyslog/libfastjson/pull/155.

Dependency on libfastjson needs to be updated to 0.99.8 or later to pick up rsyslog/libfastjson#155

Note: it's a bit tricky since libfastjson v0.99.8 contains this commit pr#155, which is different from what we'd like to have.

commit a500c1f0b5da18a4108e1844fc50fc2ed4c75a86
Merge: 9db3099 2f5789b
Author: Eric Haszlakiewicz <erh+git@nimenees.com>
Date:   Tue Mar 3 22:00:08 2015 -0500
    Merge pull request #155 from LeSpocky/bsearch
    add bsearch for arrays

Could there be a plan to release libfastjson 0.99.9 containing the 9 commits? And does this PR have a chance to be tested and merged? Thanks!

Cropi commented 3 years ago

Hi, libfastjson has been rebased to 0.99.9 . Could you rerun the tests with the latest libfastjson?