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

Support fields with spaces in the name #99

Open
rcoh opened this issue Apr 12, 2020 · 0 comments
Open

Support fields with spaces in the name #99

rcoh opened this issue Apr 12, 2020 · 0 comments

Comments

@rcoh
Copy link
Owner

rcoh commented Apr 12, 2020

eg. Date Received

wfchandler pushed a commit to wfchandler/angle-grinder that referenced this issue Jul 23, 2021
Related to rcoh#99

Currently field names containing a space or period, e.g. `date received`
or `grpc.method`, cannot be parsed. This could be worked around using
`jq` or similar tools to rewrite the field name, but that's a pain.

This commit adds an escaped field name syntax of `["<FIELD>"]` which is
based on the Object Identifier-Index syntax[0] used by `jq`, so it
should be somewhat familiar to many people who parse JSON on the
command line.

The more obvious option of delimiting with just quotes, e.g.
"date received", creates an ambiguity between string literals and
escaped field names. For example, does `where foo == "date received"`
mean field `foo` matches field `date received`, or field `foo` matches
the string "date received"?

Example query:

```
* | json | where ["grpc.method"] == "Foo" | count by ["date received"]
```

[0]
https://stedolan.github.io/jq/manual/#ObjectIdentifier-Index:.foo,.foo.bar
wfchandler pushed a commit to wfchandler/angle-grinder that referenced this issue Jul 23, 2021
Related to rcoh#99

Currently field names containing a space or period, e.g. `date received`
or `grpc.method`, cannot be parsed. This could be worked around using
`jq` or similar tools to rewrite the field name, but that's a pain.

This commit adds an escaped field name syntax of `["<FIELD>"]` which is
based on the Object Identifier-Index syntax[0] used by `jq`, so it
should be somewhat familiar to many people who parse JSON on the
command line.

The more obvious option of delimiting with just quotes, e.g.
"date received", creates an ambiguity between string literals and
escaped field names. For example, does `where foo == "date received"`
mean field `foo` matches field `date received`, or field `foo` matches
the string "date received"?

Example query:

```
* | json | where ["grpc.method"] == "Foo" | count by ["date received"]
```

[0]
https://stedolan.github.io/jq/manual/#ObjectIdentifier-Index:.foo,.foo.bar
wfchandler pushed a commit to wfchandler/angle-grinder that referenced this issue Jul 23, 2021
Related to rcoh#99

Currently field names containing a space or period, e.g. `date received`
or `grpc.method`, cannot be parsed. This could be worked around using
`jq` or similar tools to rewrite the field name, but that's a pain.

This commit adds an escaped field name syntax of `["<FIELD>"]`. This is
based on the Object Identifier-Index syntax[0] used by `jq`, so it
should be somewhat familiar to many people who parse JSON on the
command line.

The more obvious option of delimiting with just quotes, e.g.
"date received", creates an ambiguity between string literals and
escaped field names. For example, does `where foo == "date received"`
mean field `foo` matches field `date received`, or field `foo` matches
the string "date received"?

Example query:

```
* | json | where ["grpc.method"] == "Foo" | count by ["date received"]
```

[0]
https://stedolan.github.io/jq/manual/#ObjectIdentifier-Index:.foo,.foo.bar
wfchandler pushed a commit to wfchandler/angle-grinder that referenced this issue Jul 23, 2021
Related to rcoh#99

Currently field names containing a space or period, e.g. `date received`
or `grpc.method`, cannot be parsed. This could be worked around using
`jq` or similar tools to rewrite the field name, but that's a pain.

This commit adds an escaped field name syntax of `["<FIELD>"]`. This is
based on the Object Identifier-Index syntax[0] used by `jq`, so it
should be somewhat familiar to many people who parse JSON on the
command line.

The more obvious option of delimiting with just quotes, e.g.
"date received", creates an ambiguity between string literals and
escaped field names. For example, does `where foo == "date received"`
mean field `foo` matches field `date received`, or field `foo` matches
the string "date received"?

Example query:

```
* | json | where ["grpc.method"] == "Foo" | count by ["date received"]
```

[0]
https://stedolan.github.io/jq/manual/#ObjectIdentifier-Index:.foo,.foo.bar
wfchandler pushed a commit to wfchandler/angle-grinder that referenced this issue Jul 23, 2021
Related to rcoh#99

Currently field names containing a space, period, or escaped quote,
e.g. `date received` or `grpc.method`, cannot be parsed. This could
be worked around using `jq` or similar tools to rewrite the field
name, but that's a pain.

This commit adds an escaped field name syntax of `["<FIELD>"]`. This is
based on the Object Identifier-Index syntax[0] used by `jq`, so it
should be somewhat familiar to many people who parse JSON on the
command line.

The more obvious option of delimiting with just quotes, e.g.
"date received", creates an ambiguity between string literals and
escaped field names. For example, does `where foo == "date received"`
mean field `foo` matches field `date received`, or field `foo` matches
the string "date received"?

Example query:

```
* | json | where ["grpc.method"] == "Foo" | count by ["date received"]
```

[0]
https://stedolan.github.io/jq/manual/#ObjectIdentifier-Index:.foo,.foo.bar
rcoh pushed a commit that referenced this issue Jul 23, 2021
Related to #99

Currently field names containing a space, period, or escaped quote,
e.g. `date received` or `grpc.method`, cannot be parsed. This could
be worked around using `jq` or similar tools to rewrite the field
name, but that's a pain.

This commit adds an escaped field name syntax of `["<FIELD>"]`. This is
based on the Object Identifier-Index syntax[0] used by `jq`, so it
should be somewhat familiar to many people who parse JSON on the
command line.

The more obvious option of delimiting with just quotes, e.g.
"date received", creates an ambiguity between string literals and
escaped field names. For example, does `where foo == "date received"`
mean field `foo` matches field `date received`, or field `foo` matches
the string "date received"?

Example query:

```
* | json | where ["grpc.method"] == "Foo" | count by ["date received"]
```

[0]
https://stedolan.github.io/jq/manual/#ObjectIdentifier-Index:.foo,.foo.bar

Co-authored-by: Will Chandler <[email protected]>
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

No branches or pull requests

1 participant