groupon / cson-parser

Simple & safe CSON parser
BSD 3-Clause "New" or "Revised" License
133 stars 27 forks source link

Fails to parse nested objects in arrays #5

Closed mwawrusch closed 9 years ago

mwawrusch commented 10 years ago

hi guys, first of all apologies for not writing tests, I am under some severe time constraints right now.

I noticed, when using grunt-cson, which is based on this module, that the following valid coffeescript does not get parsed:

content: 
      [
                a: 'a value'
                b: 'b value'
                c: 
                    d: 'nested d'
          ,
                a: 'a value'
                b: 'b value'
      ]

It breaks on the ','. I use a temporary (ugly) workaround, but wanted to let you know.

jkrems commented 10 years ago

Seems to relate to michaelficarra/CoffeeScriptRedux#308 which describes the same problem in the redux parser.

jkrems commented 10 years ago

I'm afraid until the issue linked above is resolved, the best workaround is

content: [
  {
    a: 'a value'
    b: 'b value'
    c: 
      d: 'nested d'
  }
  {
    a: 'a value'
    b: 'b value'
  }
]

(Alternatively the the separator can be }, {)

mwawrusch commented 10 years ago

thanks jan, i just realized that. It's good enough for me. Great work, btw.

On Sat, May 24, 2014 at 9:36 AM, Jan Krems notifications@github.com wrote:

I'm afraid until the issue linked above is resolved, the best workaround is

content: [ { a: 'a value' b: 'b value' c: d: 'nested d' } { a: 'a value' b: 'b value' } ]

(Alternatively the the separator can be }, {)

— Reply to this email directly or view it on GitHubhttps://github.com/groupon/cson-safe/issues/5#issuecomment-44092537 .

cybertk commented 10 years ago

Is there any plan to support this? Seems it worked well in cson, see bevry/cson#37

jkrems commented 10 years ago

Unfortunately this is a restriction of the redux parser, it will be hard to support this without changes to redux itself. cson builds on top of coffee-script 1.x which behaves the same often but not always. So far it seemed like everyone's happy to just use the wrapping curly braces, so addressing this didn't seem high priority. Especially since the curly-less style seems to degenerate into ASCII art pretty quickly and I'm not sure if it's all that valuable to enable it. ;) But a PR to redux might be successful and I'd happily bump the version in here once it has landed.

jkrems commented 9 years ago

We are switching to coffee-script 1.x for parsing. So - hurray! - this'll work now as expected.