ohler55/oj — pull request #59 by cgriego (2013-01-10 23:42:57+00:00)
Title: BigDecimal should dump to a String, at least in compat mode

The vast majority of JSON libraries across various languages load JSON numeric data types in using floating point numbers. The only safe way to maintain the precision of BigDecimal languages with 3rd party clients is to encode the data in JSON as a String and allow client code downstream from the JSON decoder use the correct language data type. This behavior is mirrored in the JSON gem, Yajl gem, and ActiveSupport.

I left the other modes alone because I'm not sure what the loss of precision means for people who use these modes. 80.51 is one such number that, at least in Ruby 1.9, won't be equal between a Float and a BigDecimal.

```ruby
gem 'json'
require 'json'
require 'bigdecimal'
JSON.dump(BigDecimal.new("1.01")) #=> "\"0.101E1\""
```

```ruby
require 'bigdecimal'
require 'yajl'
Yajl::Encoder.encode(BigDecimal.new("1.01")) #=> "\"0.101E1\""
```

```ruby
require 'active_support/json'
BigDecimal.new("1.01").as_json #=> "1.01"
BigDecimal.new("1.01").to_json #=> "\"1.01\""
```