Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: Converting boolean values in XMLout

by ikegami (Pope)
on Jan 31, 2012 at 09:50 UTC ( #950918=note: print w/replies, xml ) Need Help??


in reply to Re^2: Converting boolean values in XMLout
in thread Converting boolean values in XMLout

decode_json uses JSON::true or JSON::false for the first instance it comes across, but then adds hash references to an existing true or false for all subsequent instances.

No, not quite.

When JSON::XS is loaded, it creates two objects

$JSON::XS::true = do { bless \(my $dummy = 1), "JSON::XS::Boolean" }; $JSON::XS::false = do { bless \(my $dummy = 0), "JSON::XS::Boolean" };

No other instances are ever created. No references to those are created. Those two objects are used everywhere.

There's probably a neat way to use Rmap to do the walking, but it was beyond my abilities I'm afraid. :(

It's refusing to visit the same reference twice. You could probably mess with its seen method (which appears to be a way at peeking at the module's internals).

Replies are listed 'Best First'.
Re^4: Converting boolean values in XMLout
by perlyogi (Acolyte) on Sep 26, 2012 at 07:53 UTC

    The exact code for perl to take into consideration multiple routes to the same node so that rmap_ref need not be called multiple times would be

    rmap_ref { $_[0]{seen} = {}; $_ = "$_" if JSON::is_bool($_) } $result;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://950918]
help
Chatterbox?
[ambrus]: I'm currently in the process of rewriting my proof of concept programs. They sort of developped organically as I was experimenting, so now I've got an ugly mess of multiple programs and one-liners held together by nothing. I'll have to rewrite them to som
[ambrus]: ething that's both cleanly organized and mostly automated.
LanX in train, bad connection
[Corion]: ambrus: Yeah - we're in that situation too, except that there is no time to do the reorganizing :-/
[LanX]: ... so my boss started a project with the newest sun servers and invited the traders to come on weekend to test it... and they were so pleased, that they forced him to keep it in production...
[ambrus]: Corion: sure, this is the long-term plan. The short term is that I have to run this ungodly mess to get results from the new input data today.
[Corion]: ambrus: Most of our "automation" is tied to process exit codes and a shell pipeline :-\
[LanX]: ... a week later they realized that one of the databases - which recorded how much the other banks due to this bank - was not correctly plugged
[ambrus]: Corion: I have no problem with exit codes and shell pipeline. My problem is that the current process requires a lot of manual intervention from me, including editing the source codes.

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (16)
As of 2017-03-29 11:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (350 votes). Check out past polls.