From: Aaron D. Gifford on 8 Mar 2010 19:40 On Mon, Mar 8, 2010 at 12:19 PM, Brian Candler <b.candler(a)pobox.com> wrote: >... If you are afraid of building an extra string, then how > about: > > def jparse(str) > return JSON.parse(str) if str =~ /\A\s*[{\[]/ > JSON.parse("[#{str}]")[0] > end Definitely more robust, since that will handle numbers too. Thanks Aaron out.
First
|
Prev
|
Pages: 1 2 Prev: Camera, Graphic and Mouse Class??? Next: where to ruby tk in gem format? |