Comments (3)
Hi Michael ... I have run into the same damn thing!!
You are not missing anything obvious.
I ran into this problem when I ported http://jsonify.org to Rails 3.1; it seems to be caused by the implementation of to_json in ActiveSupport which now relies on MultiJson ... I have not had time to pin down what exactly in ActiveSupport caused the breakage.
So, what I did for http://jsonify.org was to actually use client-side formatting in JavaScript (which was fine for me).
Now, to be honest, I wasn't overly concerned about this because the pretty printing in Jsonify really should not be used in production IMO. There is an inherent performance penalty -- Jsonify pretty printing leverages the JSON.pretty_generate (or, now with MultiJson, it passes :pretty => true which gets translated and passed down to JSON as the set of options needed for pretty generation -- that requires the JSON string to be reparsed and emitted back out. So, I basically decided to leave this as somewhat of an open bug that was not a "show stopper".
Is it a show stopper for you?
Let me know,
Bill
On Feb 14, 2012, at 1:37 PM, Michael Marconi wrote:
Hi - I've followed your instructions about getting pretty printing in a Rails 3.1 app working to no avail. I'm including my application.rb here:
require File.expand_path('../boot', __FILE__) require 'rails/all' if defined?(Bundler) # If you precompile assets before deploying to production, use this line Bundler.require(*Rails.groups(:assets => %w(development test))) # If you want your assets lazily compiled in production, use this line # Bundler.require(:default, :assets, Rails.env) end module MyApp class Application < Rails::Application # Configure the default encoding used in templates for Ruby 1.9. config.encoding = "utf-8" # Configure sensitive parameters which will be filtered from the log file. config.filter_parameters += [:password] # Pretty-print JSON output config.jsonify_format = :pretty # Enable the asset pipeline config.assets.enabled = true # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' end endThe output all runs on a single line. Am I missing something obvious, like a 'require' statement?
Reply to this email directly or view it on GitHub:
#7
from jsonify-rails.
Hi Bill - no crisis; I've been using the excellent JSON formatter. Unfortunately, so has everyone else, so it's not very responsive at the moment!
Perhaps you should remove the documentation for pretty-printing if you're not planning on making it work in the future.
Otherwise, your project is certainly making my life easier, so thank you!
Best,
Michael
from jsonify-rails.
Thanks for pointing out jsonformatter -- I had not used that.
I would definitely like to make the pretty printing work -- and it does outside of Rails (but who is using Ruby outside of Rails 8-) -- anyway, I just need to do the digging into ActiveSupport ... it's only one of 8000 things on my to-do list :)
Glad that Jsonify is helping you out -- by the way ... here's just the short little JS function (in CoffeeScript) to do my client side formatting
prettify = (json) ->
try JSON.stringify(JSON.parse(json), null, 4)
On Feb 15, 2012, at 9:55 AM, Michael Marconi wrote:
Hi Bill - no crisis; I've been using the excellent JSON formatter. Unfortunately, so has everyone else, so it's not very responsive at the moment!
Perhaps you should remove the documentation for pretty-printing if you're not planning on making it work in the future.
Otherwise, your project is certainly making my life easier, so thank you!
Best,
Michael
Reply to this email directly or view it on GitHub:
#7 (comment)
from jsonify-rails.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsonify-rails.