Can I Rende开发者_如何学JAVAr Json but from file? Not:
render :json => Some_object
Yes you can render the data from file, It has some json formatted data in the file.
render :json => jsonDataFromFile
//
def jsonDataFromFile
data = ""
file = File.new("readfile.rb", "r")
while(line = file.gets)
data += line;
end
data.to_json //return data
end
If you are confortable to use XML builder, then you may like this:
http://github.com/jbr/argonaut
精彩评论