maccman/catapult — pull request #14 by mulderp (2013-05-18 21:59:12+00:00)
Title: Provide a way to load JSON data for the server

The idea of this PR is a way to get JSON into the browser. This might be interesting when designing views for data that is loaded with Ajax, e.g some movies collection.

By putting a file ./data/movies.json with content:

[{ "title": "Midnight in Paris" }]

it is possible to load the JSON from the browser with e.g.:

$.get("/movies.json", function(data) { console.log(JSON.parse(data)); })

results into

[ { title: 'Midnight in Paris' }]

Underlying this is Sinatra reading all .json files from the ./data directory.

What do you think?