{"action":"created","issue":{"url":"https://api.github.com/repos/ohler55/oj/issues/230","labels_url":"https://api.github.com/repos/ohler55/oj/issues/230/labels{/name}","comments_url":"https://api.github.com/repos/ohler55/oj/issues/230/comments","events_url":"https://api.github.com/repos/ohler55/oj/issues/230/events","html_url":"https://github.com/ohler55/oj/issues/230","id":70030543,"number":230,"title":"Oj.dump(Float::INFINITY) should return \"null\"","user":{"login":"alanho","id":71258,"avatar_url":"https://avatars.githubusercontent.com/u/71258?v=3","gravatar_id":"","url":"https://api.github.com/users/alanho","html_url":"https://github.com/alanho","followers_url":"https://api.github.com/users/alanho/followers","following_url":"https://api.github.com/users/alanho/following{/other_user}","gists_url":"https://api.github.com/users/alanho/gists{/gist_id}","starred_url":"https://api.github.com/users/alanho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alanho/subscriptions","organizations_url":"https://api.github.com/users/alanho/orgs","repos_url":"https://api.github.com/users/alanho/repos","events_url":"https://api.github.com/users/alanho/events{/privacy}","received_events_url":"https://api.github.com/users/alanho/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-22T05:41:19Z","updated_at":"2015-04-22T22:22:50Z","closed_at":null,"body":"The [ECMA-262](http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf) explicitly stated\r\n> NOTE 4 Finite numbers are stringified as if by calling ToString(number). NaN and Infinity regardless of sign are represented as the String null.\r\n\r\nCurrently\r\n```\r\n2.2.1 :001 > require \"oj\"\r\n => true \r\n2.2.1 :002 > Oj::VERSION\r\n => \"2.12.4\" \r\n2.2.1 :003 > Oj.dump(Float::INFINITY)\r\n => \"Infinity\"\r\n```\r\n\r\n\"Infinity\" is not a valid JSON string, and raise errors in browsers. None of the 4 modes available now allow user to generate a valid JSON. Expected result should be \"null\""},"comment":{"url":"https://api.github.com/repos/ohler55/oj/issues/comments/95355413","html_url":"https://github.com/ohler55/oj/issues/230#issuecomment-95355413","issue_url":"https://api.github.com/repos/ohler55/oj/issues/230","id":95355413,"user":{"login":"ohler55","id":118856,"avatar_url":"https://avatars.githubusercontent.com/u/118856?v=3","gravatar_id":"","url":"https://api.github.com/users/ohler55","html_url":"https://github.com/ohler55","followers_url":"https://api.github.com/users/ohler55/followers","following_url":"https://api.github.com/users/ohler55/following{/other_user}","gists_url":"https://api.github.com/users/ohler55/gists{/gist_id}","starred_url":"https://api.github.com/users/ohler55/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ohler55/subscriptions","organizations_url":"https://api.github.com/users/ohler55/orgs","repos_url":"https://api.github.com/users/ohler55/repos","events_url":"https://api.github.com/users/ohler55/events{/privacy}","received_events_url":"https://api.github.com/users/ohler55/received_events","type":"User","site_admin":false},"created_at":"2015-04-22T22:22:50Z","updated_at":"2015-04-22T22:22:50Z","body":"Ar you asking for a new feature or mode?\r\n\r\nAccording to the JSON spec http://json.org infinity is not a supported number in either dumping or parsing. In strict mode Oj adheres to the spec in that regard and will raise an exception if it encounters a Float::INFINITY. The same is true if it encounter the naked string Infinity in a JSON document.\r\n\r\nSince many applications, parsers, and serializers support Infinity Oj also does in object and compat mode. The callback parsers leave that choice up to the callback function.\r\n\r\nSo I believe you are asking for a version of the parser that deviates from the JSON specification and instead is compliant with the ECMA specification. What would you think about dumping null if Oj is in :null mode instead of supporting a full ECMA mode?"}}