Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

JSON generation problems #22

Closed
wants to merge 2 commits into from

2 participants

@filemon

to_json method has to accept additional parameters. Otherwise the below mentioned exception is thrown when trying to generate a json in some cases.

wrong number of arguments (1 for 0)
/Users/jirifabian/.rvm/gems/ruby-2.0.0-p0/gems/weasel_diesel-1.2.1/lib/response.rb:354:in to_json'
/Users/jirifabian/.rvm/gems/ruby-2.0.0-p0/gems/weasel_diesel-1.2.1/lib/response.rb:88:in
to_json'
/Users/jirifabian/.rvm/gems/ruby-2.0.0-p0/gems/weasel_diesel-1.2.1/lib/response.rb:88:in `to_json'

@filemon

code snippet causing issues -> https://gist.github.com/filemon/5309833

@kamui
Collaborator

I no longer get an exception here, but the first array is ignored. This will fixed by #18.

@kamui kamui closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 4 deletions.
  1. +4 −4 lib/response.rb
View
8 lib/response.rb
@@ -24,8 +24,8 @@ def initialize
# Lists all top level simple elements and array elements.
#
# @return [Array<WeaselDiesel::Response::Element, WeaselDiesel::Response::Array>]
- def nodes
- elements + arrays
+ def nodes
+ (elements + arrays).inject({}){|hash,item| hash.merge item}
end
# Shortcut to automatically create a node of array type.
@@ -351,8 +351,8 @@ def to_hash
# Converts an element into a json representation
#
# @return [String] the element attributes formated in a json structure
- def to_json
- to_hash.to_json
+ def to_json(*args)
+ to_hash.to_json(*args)
end
def to_html
Something went wrong with that request. Please try again.