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

Less than sign "<" turns to unicode with gron tool #22

Closed
davgibbs opened this issue Sep 12, 2016 · 3 comments
Closed

Less than sign "<" turns to unicode with gron tool #22

davgibbs opened this issue Sep 12, 2016 · 3 comments

Comments

@davgibbs
Copy link

Hi @tomnomnom

Only just started to use the gron tool, so maybe I am missing something!

When I include a "<" as part of my json file, the "groned" data output includes the unicode (http://unicode-table.com/en/#003C) version of the character "<" (\u003c).

[david.gibbons@7V0DZY1 ~]$ gron --version
gron version 0.3.6
[david.gibbons@7V0DZY1 ~]$ 
[david.gibbons@7V0DZY1 ~]$ cat example.json 
{
    "glossary": {
        "title": "example glossary",
        "GlossDiv": {
            "title": "<S"
        }
    }
}
[david.gibbons@7V0DZY1 ~]$ gron example.json
json = {};
json.glossary = {};
json.glossary.GlossDiv = {};
json.glossary.GlossDiv.title = "\u003cS";
json.glossary.title = "example glossary";
[david.gibbons@7V0DZY1 ~]$ gron example.json | grep '<'
[david.gibbons@7V0DZY1 ~]$
[david.gibbons@7V0DZY1 ~]$ cat example.json | grep '<'
            "title": "<S"
[david.gibbons@7V0DZY1 ~]$

So then I cannot grep for "<" directly, even though it is in my json file.

Is this something that can be fixed? Thanks

@tomnomnom
Copy link
Owner

@davgibbs ah! That'll be a setting on the JSON decoder. The escapeHTML option from memory, on the encoder used in the quoteString function in token.go (again from memory).

I'm on holiday in the countryside at the moment with only a phone so I'm afraid I can't do an immediate fix. I'll sort it when I get back to civilisation if someone hasn't beaten me to the punch!

The ideal solution would be to implement quoteString 'properly' rather than slightly abusing JSON.Marshal, but setting the escapeHTML option would be the fastest to implement.

Thanks for raising the issue!

@tomnomnom
Copy link
Owner

@davgibbs hi! I'm back to civilisation now. Your issue should be fixed in 0.3.7 - let me know if you have any problems!

Thanks again!

@davgibbs
Copy link
Author

Just tried the new release there @tomnomnom . Looks good. Thanks!

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

2 participants