Closed tleunen closed 11 years ago
Can you explain the use case for this?
As for stringify, I would rather make it possible to have a default of 4
but be able to override (e.g. null
for no spaces)
In fact, it might we could probably allow for custom iterator for JSON.stringify
via cssOpts
which would allow you to strip down the JSON to your liking.
but still please explain your use case =)
I don't really have a usecase. I use the JSON format when I need to dynamically download some assets and display them in an application. But with the current format, there are a lot of "duplicates" values, which cause the filesize to be bigger. If we can save a bit, it's always a good thing ;)
For the custom iterator, if you're talking about implementing a custom "toJSON", then yes it will work, and it's even a better solution as it will allow everyone to implement their own JSON without creating a new template.
JSON.stringify
accepts an iterator (replacer
in the docs) for stringifying as its second parameter. That is what I was referring to.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
For your semi-use case, I would suggest composing the output from grunt-spritesmith
via JSON grunt
tasks:
https://npmjs.org/package/grunt-json-massager
https://npmjs.org/package/grunt-json-minify
https://npmjs.org/package/grunt-json-replace
http://gruntjs.com/plugins/json-
I am going to close this issue for now until it gains more critical mass from others.
I think the replacer just allows you to modify a value for a certain property, not to completely rewrite the json.
But yep, I can read the output and modify it to be in the form in which I need, but this will add an additionnal step. I can also create a custom template and create the json I need before using stringify.
Hi,
I'm thinking about creating a new JSON template, but without all the duplicates values for each sprite. What do you think of this?
And also, what do you think of removing the "spaces" param of the stringify function?