Phrogz / NeatJSON

Pretty-print your JSON in Ruby, JS, or Lua with more power than JSON.stringify or JSON.pretty_generate
http://phrogz.net/JS/NeatJSON
MIT License
108 stars 19 forks source link

use NeatJSON with ruby and Opalrb (Hotfix/immutable strings) #8

Closed bwl21 closed 8 years ago

bwl21 commented 8 years ago

I wanted to use neatJson in https://github.com/opal/opal. Of course I could have build a wrapper around the JS version, but I wanted it to use it with ruby objects.

So I had to replace the usage of mutable string by another map operation. I am not sure if it is a performance issue on large JSON objects ...

thereby I also changed neatjson.html to additionally expose the ruby version of the options.

also provide a fix for #12

Thanks for the great JSON formatter.

Phrogz commented 8 years ago

I do not accept the changes in adaea55 (or even understand why you added these). I do not understand 42bff09. And 34692a1 has nothing to do with the intent of this pull request, so it should not be part.

I'm happy to consider merging 24400cf if you make a pull request just with that, so that I can do a perf test to ensure that it's not a serious issue.

bwl21 commented 8 years ago

I added 34692a1 to make it easier to play around in http://phrogz.net/JS/neatjson/neatjson.html and copy/paste the resulting options to my ruby source code.

I will split the PR to individual ones. In particular adaea55 is a bug which occurs only in the ruby version. 42bf09 is another fix which IMHO is more close to your original fix for empty containers.

I will demo the issue with a test case.