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

Does not produce valid JSON: Uses single quotes instead of double quotes as string delimiter #3

Closed
xtaran opened this issue Oct 21, 2020 · 2 comments

Comments

@xtaran
Copy link
Contributor

xtaran commented Oct 21, 2020

Hi,

At https://github.com/dmachard/pdns-logger#json-log-format, there is written:

JSON log format

Each events generated by the pdns-logger will have the following format:

{
   "dns_message": "AUTH_QUERY",
   "socket_family": "IPv6",
   "socket protocol": "UDP",
   "from_address": "0.0.0.0",
   "to_address": "184.26.161.130",
   "query_time": "2020-05-29 13:46:23.322",
   "response_time": "1970-01-01 01:00:00.000",
   "latency": 0,
   "query_type": "A",
   "query_name": "a13-130.akagtm.org.",
   "return_code": "NOERROR",
   "bytes": 4
}

But piping the actually generated JSON into jq or jshon just generates very generic error messages:

parse error: Invalid numeric literal at line 1, column 15
[…]
json read error: line 1 column 2: string or '}' expected near '''

Reason is that the claimed to be JSON looks like this for me:

{'dns_message': 'CLIENT_RESPONSE', 'socket_family': 'IPv4', 'socket protocol': 'UDP', 'from_address': […]}

Note the single quotes instead of the double quotes from the example above.

If I replace each single quote with a double quote, both, jq and jshon are happy again.

And indeed, the JSON specification on https://www.json.org/json-en.html clearly declares that only double quotes can be used as string delimiters.

This though might be a bug in the Python json module. I'm running pdns_logger 0.0.2 on Debian 10 Buster with Python 3.7 (libpython3.7-stdlib package version 3.7.3-2+deb10u2).

dmachard added a commit that referenced this issue Oct 21, 2020
@dmachard
Copy link
Collaborator

fixed in release 0.0.3

@xtaran
Copy link
Contributor Author

xtaran commented Oct 21, 2020

Commit aab22e5 definitely fixed this issue. I now get valid JSON in my log files. Thanks!

@xtaran xtaran closed this as completed Oct 21, 2020
This issue was closed.
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