similar to: ActiveSupport's JSON decoder is incorrect.

Displaying 20 results from an estimated 10000 matches similar to: "ActiveSupport's JSON decoder is incorrect."

2009 Dec 08
0
ActiveSupport 2.3.5 and json 1.2.0 gem
Hey, I''ve tried every trick I can find, yet I''m still unable to get the json gem and ActiveSupport to play nice. No matter in which order I load json and active support, I still end up with: NoMethodError: undefined method `[]'' for #<JSON::Ext::Generator::State:0x104b7fac0> I''m trying to use the JSON object directly, *not* as a ActiveSupport backend:
2006 Oct 23
0
Using ActiveSupport::JSON in PrototypeHelper, ScriptaculousHelper
Hi all, I was looking at this ticket: http://dev.rubyonrails.org/ticket/6265 and it got me thinking: is there any reason we''re not using the tasty ActiveSupport::JSON encoder to assemble options for the various helper methods in PrototypeHelper and ScriptaculousHelper? At the moment, they use options_for_javascript() in JavaScriptHelper, which is a half-hearted JSON generator that
2009 Jul 05
2
JSON data not decoded in Rails
Hello all, I''m trying to send some json data from the browser to the server using prototype without success. On the server side ActiveSupport::JSON.decode isn''t decoding the data. Here is the code: Javacript: <a href="#" onclick=''send();return false;''>click</a> <script> function send() { var send_data_url =
2007 Dec 07
2
[ActiveSupport] Patches needing review: re-organization of #to_query methods, preservation of XML/JSON content-type
Just a quick pointer to some ActiveSupport patches hoping for reviews: Puts Array#to_query and Object#to_query in the right places in ActiveSupport - http://dev.rubyonrails.org/ticket/10395 Preserve user-specified content type for XML and JSON rendering (currently it''s overridden and set to Mime::XML/Mimi::JSON - http://dev.rubyonrails.org/ticket/10388 Oh and a tiny patch for
2010 May 28
1
cookie has key/value pairs and lost order after JSON decode
If a cookie has several items, and is encoded as JSON text as the value of the cookie, the order is actually apparent in the cookie''s text But if JSON.decode is used: ActiveSupport::JSON.decode(cookies[''item_list'']) and the result is actually in a hash, then the ordering is lost... Is it true that if the original JSON object has an array of hashes (1 key and 1
2010 Aug 26
2
Today: constant JSON::Parser not defined
(Using the latest 3-0-stable and rvm, and ruby-1.9.2-p0) Yesterday everything worked, my own changes are very minor and in the application only. Did anything change that could have caused this problem? Unfortunately simply going back in rails alone to the original "RC2" git-tag did not immediately help, so it may be some other problem (on my own system only, even if I''m
2007 Sep 28
2
Rails shouldn't output invalid JSON by default
Please check out this ticket (which would explain almost everything): http://dev.rubyonrails.org/ticket/8762 So basically, Rails to_json methods produces invalid JSON out of the box as it doesn''t quote all hash keys. This is valid JSON: { "id": 6589, "code": "SIN", "name": "Singapore" } This is not (Rails'' JSON encoders
2007 Mar 24
0
overloading to_json with JSON gem installed causing error
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
2007 Oct 02
0
More JSON and XML feature parity for AR and ActiveSupport (patch review)
I''m really glad the JSON changes got in, many thanks to all involved, committers and contributors alike :). But there''s still one feature that''s missing to achieve feature parity between the JSON and XML encoding/conversion. And that is the abililty to say in your controller: @authors = Author.find(:all) render :json => @authors.to_json(:only => :name)
2006 May 27
5
ActiveSupport JSON working?
Hi, I am trying to convert a hash to JSON using ActiveSupports built in .to_json. I am doing similar to the example below but are there certain strings that could go in place of ''bar'' or ''rez'' that will break the to_json method? I am using a very long string from rjs output in place of ''bar''. Perhaps .to_json is not ready yet? Thanks, Peter
2008 Apr 25
2
json => hash in Ruby
Hi everyone, I would like to decode a json string and transform it into a hash in ruby. I tried json = "{\"userid\" : \"21\", \"friendid\" : \"9\"}" hash = ActiveSupport::JSON.decode(json) puts hash[:userid] however, this gives NIL back. How do I have to do this? Thanks for any help! --~--~---------~--~----~------------~-------~--~----~ You
2011 Dec 13
0
Using ActiveSupport's autoload_at
After discovering http://api.rubyonrails.org/classes/ActiveSupport/Autoload.html I thought it''d be nice if we could replace our zillion occurences of: autoload :Something, ''some_path/something'' with: autoload_at ''some_path'' do autoload :Something end But I keep getting undefined method autoload_at. I tried digging - ActionSupport::Autoload is
2012 Dec 08
0
Security - How to sanizitize JSON?
Hi, I''m on Rails 3.2.8 and one of my apps sends some json to create DB objects. What''s the best way to sanitize json? I found this post claiming that for json we need to escape manually since json_escape is broken: http://blog.bigbinary.com/2012/05/10/xss-and-rails.html I tried using the sanitize gem (https://github.com/rgrove/sanitize/) but when using it on a json string it
2007 Jul 18
5
Mocking Rails association collections
Rails model association collections allow you to do nifty things like: article.comments.find(:all, :conditions => {:created_at > 1.day.ago}) Has anyone found a good way to mock this up? I''m currently doing this: @comment1 = mock_model(Comment) comments = mock(Array) comments.stub!(:find).and_return([@comment1]) @article = mock_model(Article)
2009 May 28
0
Re: ActiveResource as API test rig? Two jsons?
bump... On Wed, May 20, 2009 at 3:57 PM, Marc Byrd <dr.marc.byrd-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > Hi, > > I''m using ActiveResource as an API test rig for an API we''re developing for > our PHP app - the goal being to validate that we''re following some > externally validated conventions for ReSTful API and that we can support at >
2012 Jul 25
1
A minor beef with JSON::decode
Hiya, So, what was the impetus behind having ParamsParser create Date and DateTime objects out of application/json requests? The project I''m on expects parameters to be received as standard types (bools, numbers, strings, arrays, and hashes). Rails shouldn''t try to convert objects that are explicitly passed as these types; it should be up to the application to do that.
2008 Jan 30
0
Publish templatized action with JSON gotcha in Rails 1.2
Hey guys- to_json in Rails 1.2 produces json with unquoted keys, which is invalid. Therefore, publish_templatized_action produces invalid json for feed publishing, and you''ll get an error from Facebook. To fix this, put this line in environment.rb: ActiveSupport::JSON.unquote_hash_key_identifiers = false You don''t need to do this if you''re running Rails 2.0. Just a
2010 Oct 31
0
Error in rendering json
Hello, in my controller I use following code to render json. render :json => @product, :callback => params[:callback] I would expect (for example) following to be rendered: callback({"name":"Computer","price":500}) Instead, it renders: callback([{"name":"Computer","price":500}]) Notice the square brackets which disables
2010 Jul 05
0
Serialized JSON object importation
Hi, I would like to import a serialized object (from a JSON export) inside my database. It work fine if for instance I do: >> l = Yea.create(:title => "foo bar") => #<Yea id: 3, title: "foo bar", created_at: "2010-07-05 21:44:54", updated_at: "2010-07-05 21:44:54"> >> j = l.to_json =>
2007 Sep 01
2
Getting JSON from the body of a POST
I have a Flash application that is sending JSON data to a Rails app. I want to be able to read the JSON from the controller. Does anyone know where I can go to figure this out? I''ve Google''d around but can only find instances of converting to JSON, not the other way. Example: Flash -> Sends JSON -> Rails Controller receives JSON and converts it to a class -- Posted