Skip to content

hq doesn't accept underscores in key names #146

@fotonick

Description

@fotonick

hq doesn't accept underscores in the key names. This is surprising to me and the generic error message didn't make this limitation easy to find.

Example:

❯ echo '<div class="a">test</div>' | hq '{ a: .a }'
{"a":"test"}
❯ echo '<div class="a">test</div>' | hq '{ a_text: .a }'
Error parsing:
0: at line 1:
{ a_text: .a }
  ^
expected '}', found a

If I'm not mistaken, it's from the use of alphanumeric1 in the parsing function. Is underscore support something you would add? If it helps, there's a Stack Overflow answer that seems to have exactly the nom parser combinator invocations you need.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions