in reply to JSON module & decoding boolean data

Are you planning on changing the value of false? It's an immutable object. There's no reason to make copies of it.

  • Comment on Re: JSON module & decoding boolean data

Replies are listed 'Best First'.
Re^2: JSON module & decoding boolean data
by rovingeyes (Sexton) on Apr 22, 2010 at 07:14 UTC
    Actually I don't care for an object there at all. According to the module POD, upon decode true should become 1 & false should be represented as 0, which is what I'm looking for. So I guess what I want is instead of JSON::false, can I get 0 back upon decode.
      If you use these values (e.g. in print, if or mathematical calculation), these will work as 0 or 1

      UPDATE:

      # perl -MJSON::XS -e '$x = q/{"bool":true}/;$y=decode_json($x);print " +$y->{bool}\n"' 1

        Thanks, that is all I was looking for.