# Overloading to\_json with JSON gem installed causing error

**URL:** <https://www.ruby-forum.com/t/overloading-to-json-with-json-gem-installed-causing-error/89948>\
**Category:** Rails\
**Created:** [March 24, 2007, 3:18am UTC](https://www.ruby-forum.com/t/overloading-to-json-with-json-gem-installed-causing-error/89948 "2007-03-24T03:18:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![yottameter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/df705f/32.png) [@yottameter](https://www.ruby-forum.com/u/yottameter)\
**Post date:** [March 24, 2007, 3:18am UTC](https://www.ruby-forum.com/t/overloading-to-json-with-json-gem-installed-causing-error/89948/1 "2007-03-24T03:18:12Z")

</div>

I installed the JSON gem because I wanted the JSON parser.

Before installing the JSON gem, overloading worked fine. Before I  
remove it, I’d like to see if anyone has an idea of what is going on.  
It’s the only JSON parser I’m aware of, so it would be a bummer if it  
didn’t work.

After installing, if I overload the to\_json method in the class, it  
gives me the following error:

wrong number of arguments (2 for 0)

RAILS\_ROOT: script/…/config/…  
Application Trace | Framework Trace | Full Trace

/usr/local/lib/ruby/gems/1.8/gems/json-0.4.3/lib/json.rb:622:in  
`to_json' /usr/local/lib/ruby/gems/1.8/gems/json-0.4.3/lib/json.rb:622:in`json\_transform’  
/usr/local/lib/ruby/gems/1.8/gems/json-0.4.3/lib/json.rb:621:in  
`json_transform' /usr/local/lib/ruby/gems/1.8/gems/json-0.4.3/lib/json.rb:595:in`to\_json’  
/usr/local/lib/ruby/gems/1.8/gems/json-0.4.3/lib/json.rb:606:in  
`json_check_circular' /usr/local/lib/ruby/gems/1.8/gems/json-0.4.3/lib/json.rb:595:in`to\_json’  
app/controllers/item\_controller.rb:92:in `list’

/usr/local/lib/ruby/gems/1.8/gems/json-0.4.3/lib/json.rb:622:in  
`to_json' /usr/local/lib/ruby/gems/1.8/gems/json-0.4.3/lib/json.rb:622:in`json\_transform’  
/usr/local/lib/ruby/gems/1.8/gems/json-0.4.3/lib/json.rb:621:in  
`json_transform' /usr/local/lib/ruby/gems/1.8/gems/json-0.4.3/lib/json.rb:595:in`to\_json’  
/usr/local/lib/ruby/gems/1.8/gems/json-0.4.3/lib/json.rb:606:in  
`json_check_circular' /usr/local/lib/ruby/gems/1.8/gems/json-0.4.3/lib/json.rb:595:in`to\_json’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/  
action\_controller/base.rb:1095:in `perform_action_without_filters' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_controller/filters.rb:632:in`call\_filter’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/  
action\_controller/filters.rb:634:in `call_filter' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_controller/filters.rb:638:in`call\_filter’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/  
action\_controller/filters.rb:438:in `call' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_controller/filters.rb:637:in`call\_filter’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/  
action\_controller/filters.rb:638:in `call_filter' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_controller/filters.rb:438:in`call’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/  
action\_controller/filters.rb:637:in `call_filter' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_controller/filters.rb:619:in`perform\_action\_without\_benchmark’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/  
action\_controller/benchmarking.rb:66:in  
`perform_action_without_rescue' /usr/local/lib/ruby/1.8/benchmark.rb:293:in`measure’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/  
action\_controller/benchmarking.rb:66:in  
`perform_action_without_rescue' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_controller/rescue.rb:83:in`perform\_action’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/  
action\_controller/base.rb:430:in `process_without_filters' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_controller/filters.rb:624:in`process\_without\_session\_management\_support’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/  
action\_controller/session\_management.rb:114:in `process' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_controller/base.rb:330:in`process’  
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/dispatcher.rb:41:in  
`dispatch' /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/webrick_server.rb: 113:in`handle\_dispatch’  
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/webrick\_server.rb:  
79:in `service' /usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in`service’  
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run' /usr/local/lib/ruby/1.8/webrick/server.rb:173:in`start\_thread’  
/usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread' /usr/local/lib/ruby/1.8/webrick/server.rb:95:in`start’  
/usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start' /usr/local/lib/ruby/1.8/webrick/server.rb:23:in`start’  
/usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start' /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/webrick_server.rb: 63:in`dispatch’  
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/commands/servers/  
webrick.rb:59  
/usr/local/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`require' /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/ active_support/dependencies.rb:495:in`require’  
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/  
active\_support/dependencies.rb:342:in `new_constants_in' /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/ active_support/dependencies.rb:495:in`require’  
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/commands/server.rb:  
39  
/usr/local/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`require’  
script/server:3

/usr/local/lib/ruby/gems/1.8/gems/json-0.4.3/lib/json.rb:622:in  
`to_json' /usr/local/lib/ruby/gems/1.8/gems/json-0.4.3/lib/json.rb:622:in`json\_transform’  
/usr/local/lib/ruby/gems/1.8/gems/json-0.4.3/lib/json.rb:621:in  
`json_transform' /usr/local/lib/ruby/gems/1.8/gems/json-0.4.3/lib/json.rb:595:in`to\_json’  
/usr/local/lib/ruby/gems/1.8/gems/json-0.4.3/lib/json.rb:606:in  
`json_check_circular' /usr/local/lib/ruby/gems/1.8/gems/json-0.4.3/lib/json.rb:595:in`to\_json’  
app/controllers/item\_controller.rb:92:in `list' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_controller/base.rb:1095:in`perform\_action\_without\_filters’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/  
action\_controller/filters.rb:632:in `call_filter' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_controller/filters.rb:634:in`call\_filter’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/  
action\_controller/filters.rb:638:in `call_filter' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_controller/filters.rb:438:in`call’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/  
action\_controller/filters.rb:637:in `call_filter' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_controller/filters.rb:638:in`call\_filter’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/  
action\_controller/filters.rb:438:in `call' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_controller/filters.rb:637:in`call\_filter’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/  
action\_controller/filters.rb:619:in `perform_action_without_benchmark' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_controller/benchmarking.rb:66:in`perform\_action\_without\_rescue’  
/usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_controller/benchmarking.rb:66:in`perform\_action\_without\_rescue’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/  
action\_controller/rescue.rb:83:in `perform_action' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_controller/base.rb:430:in`process\_without\_filters’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/  
action\_controller/filters.rb:624:in  
`process_without_session_management_support' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_controller/session_management.rb:114:in`process’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/  
action\_controller/base.rb:330:in `process' /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/dispatcher.rb:41:in`dispatch’  
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/webrick\_server.rb:  
113:in `handle_dispatch' /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/webrick_server.rb: 79:in`service’  
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' /usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in`run’  
/usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread' /usr/local/lib/ruby/1.8/webrick/server.rb:162:in`start\_thread’  
/usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start' /usr/local/lib/ruby/1.8/webrick/server.rb:92:in`start’  
/usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start' /usr/local/lib/ruby/1.8/webrick/server.rb:82:in`start’  
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/webrick\_server.rb:  
63:in `dispatch' /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/commands/servers/ webrick.rb:59 /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`require’  
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/  
active\_support/dependencies.rb:495:in `require' /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/ active_support/dependencies.rb:342:in`new\_constants\_in’  
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/  
active\_support/dependencies.rb:495:in `require' /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/commands/server.rb: 39 /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`require’  
script/server:3
