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

problem parsing valid JSON array #80

Open
electerious opened this issue Apr 9, 2016 · 3 comments
Open

problem parsing valid JSON array #80

electerious opened this issue Apr 9, 2016 · 3 comments

Comments

@electerious
Copy link

My .rc file contains a valid JSON starting with a square bracket:

[
  { "hello": "world" }
]

And rc outputs the following:

{ '[': true,
  '{ "hello": "world" }': true,
  ']': true,
  _: [],
  configs: [ '/Users/tobiasreich/Sites/Rosid/.rosidrc' ],
  config: '/Users/tobiasreich/Sites/Rosid/.rosidrc' }

I tested the strip-json-comments module and it's not causing this problem. I guess it's because rc tries to merge the JSON with the defaults.

@legodude17
Copy link

The problem is caused by the auto detection of ini. The parser parses anything that starts with { as JSON and anything else as ini. My PR (#85) will actually fix that.

@dominictarr
Copy link
Owner

it doesn't make sense to use a array inside an rc config file. this should be treated as an error.

@legodude17
Copy link

Even if you think of that as an error, parsing it as ini is definitely the wrong response. Maybe you could just error if the first char is [ and it is on its own line?

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

3 participants