Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 流中有多个JSON对象_Ruby On Rails_Ruby_Json - Fatal编程技术网

Ruby on rails 流中有多个JSON对象

Ruby on rails 流中有多个JSON对象,ruby-on-rails,ruby,json,Ruby On Rails,Ruby,Json,我试图在一个视图中执行两个helper函数,调用第二个,返回第一个。我知道以下函数正确返回所需的哈希: %p = helper_method0 params[:some_string] #does a request on a third party site which responds with json data wich is then parsed by yajl and the hash is returned to view 但是,当我调用以下命令时: - hash = hel

我试图在一个视图中执行两个helper函数,调用第二个,返回第一个。我知道以下函数正确返回所需的哈希:

%p = helper_method0 params[:some_string] #does a request on a third party site which  responds with json data wich is then parsed by yajl and the hash is returned to view
但是,当我调用以下命令时:

- hash = helper_method0 params[:some_string] #does a request on a third party site which  responds with json data wich is then parsed by yajl and the hash is returned to view
%p= helper_method1 hash #Literally is just returning the input parameter
我收到以下错误消息

 Found multiple JSON objects in the stream but no block or the on_parse_complete callback was assigned to handle them.

如何调用一个带有输入参数的方法作为从视图返回的另一个方法?

您所做的完全正确:)

您也可以这样做:
(如果要保存字节和变量)


但无论如何…
这个错误听起来像是json解析器中的一个问题。。。您正在使用Yajl吗

我在像这样使用Yajl时看到了这个问题:

parser = Yajl::Parser.new
hash = parser.parse(some_string)
Yajl::Parser.parse(some_string.strip)
对我有效的方法是使用Yajl类方法,如下所示:

parser = Yajl::Parser.new
hash = parser.parse(some_string)
Yajl::Parser.parse(some_string.strip)

我希望这有帮助:)

你所做的完全正确:)

您也可以这样做:
(如果要保存字节和变量)


但无论如何…
这个错误听起来像是json解析器中的一个问题。。。您正在使用Yajl吗

我在像这样使用Yajl时看到了这个问题:

parser = Yajl::Parser.new
hash = parser.parse(some_string)
Yajl::Parser.parse(some_string.strip)
对我有效的方法是使用Yajl类方法,如下所示:

parser = Yajl::Parser.new
hash = parser.parse(some_string)
Yajl::Parser.parse(some_string.strip)
我希望这有帮助:)