Perf isn't that much better using RegExp before hand to determine if String is JSON. This also causes problems b/c YAML can look like JSON in some cases, but throws an Exception when attempting to parse. If using try/catch is needed for the second case anyway, just abandon the RegExp all together.
Benchmarks: https://gist.github.com/mzabriskie/fe85e6ea69b5049d17dd