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

pyhocon does not handle backslashes the same way json does #171

joelgrus opened this Issue Jun 19, 2018 · 1 comment


None yet
2 participants
Copy link

joelgrus commented Jun 19, 2018

In [1]: import json, pyhocon

In [2]: single = r'{"a": "b\.c"}'

In [3]: double = r'{"a": "b\\.c"}'

In [4]: json.loads(single)

In [5]: json.loads(double)
Out[5]: {'a': 'b\\.c'}

In [6]: pyhocon.ConfigFactory.parse_string(single)
Out[6]: ConfigTree([('a', 'b\\.c')])

In [7]: pyhocon.ConfigFactory.parse_string(double)
Out[7]: ConfigTree([('a', 'b\\\\.c')])

In [8]: json.dumps(json.loads(double))
Out[8]: '{"a": "b\\\\.c"}'

In [9]: json.dumps(json.loads(double)) == double
Out[9]: True

In [10]: json.dumps(pyhocon.ConfigFactory.parse_string(double))
Out[10]: '{"a": "b\\\\\\\\.c"}'

In [11]: json.dumps(pyhocon.ConfigFactory.parse_string(double)) == double
Out[11]: False

I looked at the HOCON documentation and I couldn't find explicit guidance, but I'd expect that my single example would be invalid HOCON (it's invalid JSON?) and that my double example would get parsed the same way that json.loads does it?


This comment has been minimized.

Copy link

roee30 commented Jul 8, 2018

Does this have a fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment