Skip to content

New JSON Parser#9246

Merged
reimda merged 42 commits intoinfluxdata:masterfrom
sspaink:jsonparser
Jun 10, 2021
Merged

New JSON Parser#9246
reimda merged 42 commits intoinfluxdata:masterfrom
sspaink:jsonparser

Conversation

@sspaink
Copy link
Copy Markdown
Contributor

@sspaink sspaink commented May 6, 2021

  • Updated associated README.md.
  • Wrote appropriate unit tests.

Close #9197, #1363

This pull request introduces a new JSON Parser called json_v2 that is intended to be more flexible then the existing JSON parser.

The query language being used will still be GJSON Path Syntax, but the way to configure this parser has changed significantly. I've provided multiple configuration examples within the testdata directory under the json_v2 directory. The README.md also goes into more detail on how the configuration works.

Issues closed:

@telegraf-tiger telegraf-tiger bot added new plugin plugin/parser 1. Request for new parser plugins 2. Issues/PRs that are related to parser plugins labels May 6, 2021
@influxdata influxdata deleted a comment from telegraf-tiger bot May 16, 2021
@influxdata influxdata deleted a comment from telegraf-tiger bot May 16, 2021
@influxdata influxdata deleted a comment from telegraf-tiger bot May 16, 2021
@sspaink sspaink changed the title New JSON Parser using JSONpath New JSON Parser May 17, 2021
@samhld
Copy link
Copy Markdown
Contributor

samhld commented Jun 3, 2021

@sspaink @sjwang90

This is so cool! I tested it out and it works great! I'll file the "zip" feature request today.

Two notes from testing:

  • I'm wondering if the syntax of [[xxx.xxx.json_v2.object]] and [[xxx.xxx.json_v2.tag]], etc. is unnecessarily verbose? In the examples, the inputs.file portion seems to be implied, right? Is there a technical reason we wouldn't revert back to simply [[object]], [[tag]], etc.? The TOML indentations seem to make it clear what the prefixes would be IMO.
  • If we do stick with the longer form, it might be good to explain what the xxx notation is in the example configurations (maybe just a comment // where 'xxx' is ...)

@sspaink
Copy link
Copy Markdown
Contributor Author

sspaink commented Jun 3, 2021

@samhld thanks for the feedback! This is a limitation of TOML that sub-tables needs the parent name. I agree it would be nicer if it was just object/field/tag. I did update the README to be more clear and removed "xxx" with an actual example.
Spec for reference: https://github.com/toml-lang/toml/blob/master/toml.md#table

@samhld
Copy link
Copy Markdown
Contributor

samhld commented Jun 3, 2021

@sspaink Oh gotcha! TIL!

@sspaink sspaink marked this pull request as ready for review June 4, 2021 01:47
Sebastian Spaink added 2 commits June 10, 2021 11:17
* `uint`, bool, floats or strings (with valid numbers) can be converted to a uint.
* `string`, any data can be formatted as a string.
* `float`, string values (with valid numbers) or integers can be converted to a float.
* `bool`, the string values "true" or "false" (regardless of capitalization) or the integer values `0` or `1` can be turned to a bool.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be worth it to add a section for people upgrading from v1?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, we should look into adding this. Need to get some example configs from v1.

Copy link
Copy Markdown
Contributor

@reimda reimda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

@reimda reimda merged commit 885252d into influxdata:master Jun 10, 2021
@reimda reimda linked an issue Jun 10, 2021 that may be closed by this pull request
reimda pushed a commit that referenced this pull request Jun 10, 2021
(cherry picked from commit 885252d)
arstercz pushed a commit to arstercz/telegraf that referenced this pull request Aug 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new plugin plugin/parser 1. Request for new parser plugins 2. Issues/PRs that are related to parser plugins

Projects

None yet

3 participants