rovingeyes has asked for the wisdom of the Perl Monks concerning the following question:
and when I decode it by JSON->new->allow_nonref(1)->utf8(1)->decode on the above stream, I get the following output:{"value":[{"name":"THICNT","value":"1","secure":false,"path":"/","doma +in":"www.google.com","class":"org.openqa.selenium.internal.ReturnedCo +okie"},{"name":"NID","value":"34=pqQMsEqv3oAfy8-qWv-WEYBusldqUSoe_9Tg +iSoaN0itw7","secure":false,"path":"/","domain":".google.com","class": +"org.openqa.selenium.internal.ReturnedCookie"},{"name":"PREF","value" +:"ID=3f5070f587c10823:U=4e8ab4b3b6576160:TM=1271918988:LM=1271918988: +S=NZ9UTF7eCxicziqM","secure":false,"path":"/","domain":".google.com", +"class":"org.openqa.selenium.internal.ReturnedCookie"}]}
$VAR1 = [ { 'domain' => 'www.google.com', 'value' => '1', 'secure' => bless( do{\(my $o = 0)}, 'JSON::XS::Boolean' ) +, 'name' => 'THICNT', 'class' => 'org.openqa.selenium.internal.ReturnedCookie', 'path' => '/' }, { 'domain' => '.google.com', 'value' => '34=pqQMsEqv3oAfy8-qWv WEYBusldqUSoe_9TgiSoaN0i +tw7', 'secure' => $VAR1->[0]{'secure'}, 'name' => 'NID', 'class' => 'org.openqa.selenium.internal.ReturnedCookie', 'path' => '/' }, { 'domain' => '.google.com', 'value' => 'ID=3f5070f587c10823:U=4e8ab4b3b6576160:TM=1271 +918988:LM=1271918988:S=NZ9UTF7eCxicziqM', 'secure' => $VAR1->[0]{'secure'}, 'name' => 'PREF', 'class' => 'org.openqa.selenium.internal.ReturnedCookie', 'path' => '/' } ];
As you can see it is an array of all the cookies, but that is irrelevant. What is relevant is that the 'secure' key's value is boolean. And the first occurrence of secure's value is an actual blessed reference & the remaining such occurrences are references to that first blessed reference.
So my question is simple - how can I invoke decode so that each boolean value is its own blessed reference rather than a reference to an already existing value? Or is that just by design & that is the only way JSON.pm decodes data?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: JSON module & decoding boolean data
by ikegami (Patriarch) on Apr 22, 2010 at 07:04 UTC | |
by rovingeyes (Sexton) on Apr 22, 2010 at 07:14 UTC | |
by samarzone (Pilgrim) on Apr 22, 2010 at 07:54 UTC | |
by rovingeyes (Sexton) on Apr 22, 2010 at 18:39 UTC |