I'd be cautious about using a big regex like this without any test cases.

You could do a couple of `begin...rescue...end` blocks around `Integer(json_object)` and `Float(json_object)` and check for `ArgumentError`s, but that would be less compact.