GithubHelp home page GithubHelp logo

Array at root? about cpp-hocon HOT 4 OPEN

tamboril avatar tamboril commented on May 27, 2024
Array at root?

from cpp-hocon.

Comments (4)

Magisus avatar Magisus commented on May 27, 2024

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.

from cpp-hocon.

tamboril avatar tamboril commented on May 27, 2024

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} ]

from cpp-hocon.

Magisus avatar Magisus commented on May 27, 2024

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.

from cpp-hocon.

MikaelSmith avatar MikaelSmith commented on May 27, 2024

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.

from cpp-hocon.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.