Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^9: Is there a way to make a JSON out of multiple records from MySQL?

by AnomalousMonk (Archbishop)
on May 13, 2022 at 05:50 UTC ( [id://11143865]=note: print w/replies, xml ) Need Help??


in reply to Re^8: Is there a way to make a JSON out of multiple records from MySQL?
in thread Is there a way to make a JSON out of multiple records from MySQL?

... my $typehint_raws = [ ($typehint_raw) x @$arrayref]; my $json = encode_json($arrayref, $typehint_raws); return $json; ...
I'm looking at $typehint_raws just before calling the encode_json command.

If you're dumping $typehint_raws just before calling encode_json(), then you're dumping it just after initializing it (according to the posted code). In that case, the situation is just as given in the example here except that it's a hash reference that's being replicated rather than an array ref.

I don't know what encode_json() does to "fill in" $typehint_raws, but it doesn't seem that it can be of much consequence since $typehint_raws goes out of scope with the return statement that immediately follows the subroutine call.


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^10: Is there a way to make a JSON out of multiple records from MySQL?
by bartender1382 (Beadle) on May 15, 2022 at 18:22 UTC

    I don't know what encode_json() does to "fill in" $typehint_raws, but it doesn't seem that it can be of much consequence since $typehint_raws goes out of scope with the return statement that immediately follows the subroutine call.

    Not sure why you say that. I've run the code dozens of times, on multiple tables and searches. Not just getting back the proper output, but my server error log shows no errors.

    still asking because I don't want to get bit in the rear later on.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11143865]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-25 12:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found