Hacker News new | ask | show | jobs
by culi 1098 days ago
Ruby, being a Perl-inspired language, has `.to_json` built in. You can do

```rb

   # hashes
   { foo: 'bar' }.to_json
   
   # numbers
   28.to_json

   # anything really
   ['hello', 42, { lorem: "ipsum" }].to_json
```
1 comments

That’s simply not true. This method is monkeypatched by json gem
JSON was added to Ruby stdlib in ruby-2.0.0 (2013), and has been a default gem since ruby-2.3.0 (2015).

This is pretty close to "built in", I think.

You're both right, I think.