-
Notifications
You must be signed in to change notification settings - Fork 8
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
SUBSEP #4
Comments
Hi thanks for the feedback. I think that 1-byte string (\034) is generally the default value of SUBSEP. And awk automatically translates code of the form What part of the code gave you the impression that I was assuming SUBSEP was set to comma? I acknowledge I don't have this stuff loaded into my working memory right now, but I don't think I was making that assumption. |
Well I don't know then, Try running query_json() with this {"results": [{"url": "http://nytimes.com", "timestamp": "20070101", "archived_snapshots": {"closest": {"status": "200", "available": true, "url": "http://web.archive.org/web/20061231083247/http://www.nytimes.com:80/", "timestamp": "20061231083247"}}}]} It produces weird output. Only by setting SUPSEP to comma does it work. |
produces:
There's no need to change the definition of After running Everytime I say something like |
Sorry, when I just wrote |
Ahh dump(). I was doing:
It appears that because the index ('i') contains \034 it prints to the screen a sort of Chinese-looking block character that overwrites other characters giving a strange result. It's supposed to be non-printing but it prints. It wasn't the comma exactly rather any character other than \034 fixed it. In dump():
which corrects it for display purposes. It was not clear why that strange output was occurring then I narrowed it down to the SUBSEP thinking it required a comma, but really the problem was SUBSEP needs to be gsub()'d before displaying. I just read more carefully about multi-dimensional arrays and SUBSEP and you are right, this is how its done, it makes sense. My only suggestion maybe, since this could be a common gotcha, would be an inline comment to use dump() to properly display the results of json_query() |
Well, I expected the normal use would be something like:
|
Yes but how would one know the string to search for is |
query_json() assumes SUBSEP is set to "," (comma) but SUBSEP is not defined anywhere. In Gawk, the default value of SUBSEP is the string "\034" which causes unusual display output. I've never seen json that didn't use comma so will hard-code it for my purposes, but maybe it's worth keeping as a variable and document somewhere as being adjustable. Couple other functions use SUBSEP that might also have trouble with Gawk.
Nice work BTW I'll be using some the functions.
The text was updated successfully, but these errors were encountered: