Skip to content

Converting part of record to json string #8193

@MrKich

Description

@MrKich

Is your feature request related to a problem? Please describe.
I could not find a feature to simply convert part of parsed record back to json.
Typical usage for me is when I need to parse deep nested json, extract (lift) and rename some deep fields in it and then return part of parsed record as string.

E.g. using zalando logbook (java spring) can produce json logs, which after parsing look like this:

{
  "origin": "remote",
  "type": "request",
  "correlation": "2d66e4bc-9a0d-11e5-a84c-1f39510f0d6b",
  "protocol": "HTTP/1.1",
  "sender": "127.0.0.1",
  "method": "GET",
  "uri": "http://example.org/test",
  "host": "example.org",
  "path": "/test",
  "scheme": "http",
  "port": null,
  "headers": {
    "Accept": ["application/json"],
    "Content-Type": ["application/json"]
  },
  "body": {"test": [1,2,3]}
}

I want to change 'body' value from object to string (e.g. "body": "{\"test\": [1,2,3]}" ).

Describe the solution you'd like
I think it is possible to implement a new 'config_parameter' for filter 'type-converter' to encode record type as json string or may be just another new filter.

Describe alternatives you've considered
I tried to use lua to convert records to json strings, but it implies using an external lua library for that, which is not handy and simple.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions