shama / grunt-minjson

A Grunt plugin for minifying json files.
MIT License
11 stars 2 forks source link

JSON5 vs JSON #8

Closed brunomperes closed 9 years ago

brunomperes commented 9 years ago

Hi @shama , After pushing #7, the outputted JSON seemed to be with the keys on the first depth without quotes on my input (no idea why), which was making my Angular application crash because it uses the standard JSON.stringify() instead of JSON5.

So I was wondering why using the JSON5, as it could generate JSONs that aren't supported on other applications. Perhaps parameterizing the usage of JSON5 in favor of the standard version of JSON or JSON3?

shama commented 9 years ago

Oh wow, could you gist an example JSON file that causes this so I can take a look? If JSON5 is generating invalid JSON that is totally a bug.

brunomperes commented 9 years ago

It seems that the problem is with json5 v0.4.0, see the changelog. They now remove quotes on keys wherever possible. Something as this

{"key":"value"}

will output as:

{key:"value"}

To test on your machine make sure you have the v0.4 (it took me a while, check the package.json of the json5 module after a npm install).

alebianco commented 9 years ago

definitively an issue, the minified json have all keys unquoted and are unusable on most applications

brunomperes commented 9 years ago

@shama any update on that? I'm happy to send a PR moving back to the default JSON.stringify method soon

shama commented 9 years ago

+1 thank you @brunomperes!

shama commented 9 years ago

Closed by https://github.com/shama/grunt-minjson/commit/5180debb1badd2c6a74d3e8beb2e16dcc5e46cc5