gpt4 book ai didi

ruby-on-rails - 在 Rails 中渲染 JSON

转载 作者:太空宇宙 更新时间:2023-11-03 18:21:47 24 4
gpt4 key购买 nike

我想查看以下json格式的代码。当我这样做时,我得到一个没有内容的空白页面。在 ruby​​mine 调试器中,我有 json 格式的正确信息。

include Java

require 'net/http'

class PatientRecordController < ApplicationController

def index
url = 'http://localhost:8080/patient/record/v2/'
data_raw = Net::HTTP.get_response(URI.parse(url)).body

@data_json = ActiveSupport::JSON.decode(data_raw)

respond_to do |format|
format.json {render json: @data_json}
end

end
end

最佳答案

您必须在您输入浏览器的路径末尾添加.json

关于ruby-on-rails - 在 Rails 中渲染 JSON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17030470/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com