Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to load JSON data for the server #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mulderp
Copy link

@mulderp mulderp commented May 18, 2013

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?

@mulderp
Copy link
Author

mulderp commented May 18, 2013

Additionally, some interesting variation might be include Redis or some store to load data from a DB, instead of files.

@lucasmazza
Copy link
Contributor

Isn't easier to place your file inside public and let the Static server serve it? (I guess it should work)

@mulderp
Copy link
Author

mulderp commented May 19, 2013

Thanks, indeed, placing the JSON in the public works too. The approach with Sinatra then only would make sense, when a resources/files would be created, or a database would be involved.

@mulderp
Copy link
Author

mulderp commented May 19, 2013

Well, some of the original idea was to have some way to get started with API development in Ruby too. A similar approach to: http://www.arangodb.org/foxx and more ideas on API co-development here: http://www.arangodb.org/2013/05/14/ideas-and-facts-from-scotland-js-in-edinburgh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants