Array at root?
If the JSON I want is an array at the top level, how do I parse that from a HOCON string?
I get an exception when parsing "[ { op: replace } ]" string: has type list rather than object at file root
JSON specifically does not allow you to parse something that does not have curly braces at root. Reading through the docs, it looks like HOCON allows you to omit the curly braces, but it still assumes that the thing at root can be converted to an object, which a list cannot. You could try adding curly braces around it (not sure if that's an option). I'd need to investigate more to come up with other solutions, but the code that is erroring is here: https://github.com/puppetlabs/cpp-hocon/blob/master/lib/src/parseable.cc#L124. That function is the last thing called before the config object gets returned, so it attempts to coerce everything to an object at the top level.
After double-checking RFC 4627, I'm pretty sure an array at the top is allowed. It can be either an object or an array.
Works with nlohmann's library and on jsonlint.com: [ {"a": 1} ]
Yeah you're right, I found the place that specifies that now... I'll have to play around with it more to see if we ever tested that functionality, and if not, where our code differs from the code that supports that.
https://github.com/lightbend/config/blob/master/HOCON.md#include-semantics-merging specifically talks about this behavior of both HOCON and JSON, and how included files differ.