Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NameValueList new parameter : ignore_whitespaces #358

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KGuillemot
Copy link
Contributor

Description

I propose to add a new option to the "name-value-list" object for liblognorm V2 : ignore_whitespaces
The purpose of this option is to ignore spaces at the beginning and the end of keys and values.
Default behavior is not affected.

Old behavior

Historically, every caracters, even spaces, that are before and after separator and assignator are captured by name-value-list type.
For example :
Using the following rule :

version=2
rule=:%{"name":".", "type":"name-value-list", "separator":",", "assignator":":"}%

the following string :
a: b, c: d
will give the following result :

{"a":" b", " c":" d"}

Note the presence of spaces in front of the value " b" and the key " c".
This can lead to issues when we want to use those variables afterwards.

New behavior

With the use of ignore_whitespaces option, all spaces around keys and values will be trimmed.
For example :
Using the following rule :

version=2
rule=:%{"name":".", "type":"name-value-list", "separator":",", "assignator":":", "ignore_whitespaces":true}%

the following string :
a: b, c: d
will give the following result :

{"a":"b", "c":"d"}

Good to know

Default and historic behavior does not change. This is a new option.
Spaces are not trimmed for quoted keys and values.

@KGuillemot
Copy link
Contributor Author

Hello,
Some tests were not successful, but it seems to be an issue with the docker environment.
Regards,
Kévin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant