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

Parsing error when loading JSON file containing quoted, multi-key/value dict. #138

Open
enlightenalpha opened this issue Nov 2, 2017 · 3 comments

Comments

@enlightenalpha
Copy link

I have a HOCON file which contains many key values similar to the following:

value: "{\"critical\":\"0.00\",\"warning\":\"99.99\"}"

When trying to parse, I receive the following exception:

Virtualenvs/cloudera/lib/python2.7/site-packages/pyparsing.pyc

in parseString(self, instring, parseAll)
1630 else:
1631 # catch and re-raise exception from here, clears out pyparsing internal stack trace
-> 1632 raise exc
1633 else:
1634 return tokens

ParseSyntaxException: Expected "}" (at char 32936), (line:893, col:74)

The file validates against several HOCON linters. Why are escaped double quotes not supported?

@enlightenalpha enlightenalpha changed the title Get parsing error when HOCON file includes escaped quotes in key value Parsing error when HOCON file includes escaped quotes in key value Nov 2, 2017
@enlightenalpha
Copy link
Author

Update - when I remove the escaped quotes, pyhocon is able to parse the file just fine.
Question - why should I have to remove them? It's valid JSON/HOCON.

@enlightenalpha
Copy link
Author

Any ideas / thoughts on how to handle this or if this is expected behavior? As I mentioned, I can get around it by removing the escaped quotes, but this is a risky proposition as I'm ruining the integrity of the original values which leads to serialization errors.

@enlightenalpha
Copy link
Author

So, it looks like the problem centers around the fact that the value being parsed contains 2 comma delimited key:value pairs:

"{"warning":500,"critical":"never"}"

If I change it to: "{"warning":500}"

...the parser doesn't complain. However, this isn't the value I need to pass so defeats the purpose.

I see the same behavior with the following value:

"morphlines:[\n {\n id:common\n importCommands:["org.kitesdk.morphline.", "com.ngdata."]"

The parser does not like the comma delimited portion of the importCommands chunk, however this is all part of a value so I'm not sure why the parser is trying to process:

ParseSyntaxException: Expected "}" (at char 33173), (line:616, col:115)

@enlightenalpha enlightenalpha changed the title Parsing error when HOCON file includes escaped quotes in key value Parsing error when loading JSON file containing quoted, multi-key/value dict. Dec 9, 2017
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

1 participant