[syslog-ng] [PATCH (3.4) 0/4]: json-parser updates

Balazs Scheidler bazsi at balabit.hu
Mon Jan 16 22:40:50 CET 2012


On Tue, 2012-01-10 at 13:11 +0100, Gergely Nagy wrote:
> Following this mail, a couple of patches will come - they were written
> in last November, but I don't think I posted them (as I didn't expect
> to see the json-parser merged so soon). Until now, they were sitting
> on my feature/3.4/json/parser branch, and that's where they sit now,
> too.
> 
> I rebased that branch onto 3.4 master + center.c syntax error fixes
> (which I posted a week or two ago), and am sending the json parser
> patches now.
> 
> They accomplish a few things: it makes the parser handle invalid JSON
> input properly (by returning an error, instead of crashing); adds
> support for parsing boolean, array and nested object types.
> 
> Booleans will get parsed into TRUE or FALSE, nested objects will be
> turned into dotted notation (which also means that keys with a dot in
> them won't be handled properly by format-json, once it is updated to
> support reconstructing nested objects from dotted notation), and
> arrays will be treated like nested objects, with the array indexes
> used as a key.
> 
> As an example, lets look at a JSON input:
> 
> {"is-example": true,
>  "hats": ["top hat", "baseball cap", "pointy witch-hat"],
>  "auth": {
>    "method": ["looking angry at the security guy", "bribery"],
>    "result": "did not work"
>  }
> }
> 
> This would be parsed into the following name-value paris:
> 
> "is-example"="TRUE"
> "hats.0"="top hat"
> "hats.1"="baseball cap"
> "hats.2"="pointy witch-hat"
> "auth.method.0"="looking angry at the security guy"
> "auth.method.1"="bribery"
> "auth.result"="did not work"
> 
> The other part of this will be an enhahcement to value-pairs and
> format-json, that will make syslog-ng able to reconstruct the original
> JSON (more or less... booleans probably won't be supported, except
> perhaps optionally with a flag). But that is something I haven't
> started working on yet.

Merged all of this, however it'd be nice if format-json could actually
handle the output of this parser.

Thanks Gergely.

-- 
Bazsi




More information about the syslog-ng mailing list