Can you tell me where JSON is practically used in real world rails applications?
I think usually, you convert Model to json format. And then what do you do with that json?
How does one decide whether JSON is required in a particular rails application or not?
Let me answer (3) first, because it's the most important answer. Never, ever try to pre-empt requirements. If you're pondering whether or not JSON output is required - then it's not! Only add it in when a requirement arises that requires it.
So, (1) and (2) are essentially the same question.
So, as you can see these are very specific purposes - unless you need these specific features, then there's no reason to even consider it.
ok, so we could use it for AJAX requests. Few more questions are bothering me, 4. Is there any application where the data itself will be in JSON format (like sometimes the data is stored in XML)? Does this happen in real world apps? 5. What about YAML, what kind of data is stored in yml files? (other than fixtures). 6. How often or rarely is the data stored in yml / JSON? (instead of database) Thanks
People tend to use YAML for seed data and/or configuration data (because it's easier to change in a text editor than having to connect to a database and change it there). I don't know that I've heard of any reason to store data in JSON.
How often? I rarely do it, I don't really see the point of storing data in YAML when it's so simple to just store it in the DB, and provide a CRUD admin to the data for your users. Other people may have more obvious situations where YAML makes sense.