• dump all object keys/valu

    From Mortifis@VERT/ALLEYCAT to All on Tue Apr 7 21:42:00 2020
    How would one show all of the key/values for http_request.query?

    Thanks,

    ~Mortifis

    ---
    Synchronet AlleyCat! BBS Lake Echo, NS Canada
  • From echicken@VERT/ECBBS to Mortifis on Tue Apr 7 20:53:00 2020
    Re: dump all object keys/values
    By: Mortifis to All on Wed Apr 08 2020 01:42:22

    How would one show all of the key/values for http_request.query?

    Object.keys(http_request.query).forEach(function (e) {
    writeln(e + ': ' + JSON.stringify(http_request.query[e]));
    });

    Because each property of http_request.query is an array, I'm JSON.stringifying the value to dump the array contents.

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com
    Synchronet electronic chicken bbs - bbs.electronicchicken.com
  • From Mortifis@VERT/ALLEYCAT to echicken on Wed Apr 8 05:01:00 2020
    Thank you, very much ... I was close but no cigar .. take care & stay safe

    ~Mortifis

    ---
    Synchronet AlleyCat! BBS Lake Echo, NS Canada
  • From Nightfox@VERT/DIGDIST to Mortifis on Wed Apr 8 08:29:00 2020
    Re: dump all object keys/values
    By: Mortifis to All on Wed Apr 08 2020 01:42 am

    How would one show all of the key/values for http_request.query?

    To print out the key/values of an object, I usually like to do this (this example assumes it's being run on the telnet terminal:

    for (var prop in http_request.query)
    console.print(prop + ": " + http_request.query[prop] + "\r\n"); console.pause();

    Nightfox

    ---
    Synchronet Digital Distortion: digitaldistortionbbs.com
  • From Digital Man@VERT to Nightfox on Wed Apr 8 08:59:00 2020
    Re: dump all object keys/values
    By: Nightfox to Mortifis on Wed Apr 08 2020 12:29 pm

    Re: dump all object keys/values
    By: Mortifis to All on Wed Apr 08 2020 01:42 am

    How would one show all of the key/values for http_request.query?

    To print out the key/values of an object, I usually like to do this (this example assumes it's being run on the telnet terminal:

    for (var prop in http_request.query)
    console.print(prop + ": " + http_request.query[prop] + "\r\n"); console.pause();

    JSON.stringify() does seem easier though:

    console.print(lfexpand(JSON.stringify(http_request.query, null, 4)));

    digital man

    Synchronet "Real Fact" #88:
    SBBSecho v3.00 was first committed to cvs.synchro.net on Apr-11-2016.
    Norco, CA WX: 54.1F, 68.0% humidity, 7 mph NNE wind, 0.78 inches rain/24hrs

    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From Nightfox@VERT/DIGDIST to Digital Man on Wed Apr 8 11:25:00 2020
    Re: dump all object keys/values
    By: Digital Man to Nightfox on Wed Apr 08 2020 12:59 pm

    To print out the key/values of an object, I usually like to do this
    (this example assumes it's being run on the telnet terminal:

    for (var prop in http_request.query)
    console.print(prop + ": " + http_request.query[prop] + "\r\n");
    console.pause();

    JSON.stringify() does seem easier though:

    console.print(lfexpand(JSON.stringify(http_request.query, null, 4)));

    Interesting, I'll have to try that.

    Nightfox

    ---
    Synchronet Digital Distortion: digitaldistortionbbs.com
  • From Mortifis@VERT/ALLEYCAT to echicken on Fri Apr 10 09:31:00 2020
    I suppose a generic function might look like:

    function dump_objs(obj)
    {
    Object.keys(obj).forEach(function (e) {
    writeln(e + ': ' + JSON.stringify(obj[e]) + '<br>'); // run via an xjs script for html output
    });
    }

    // and a possible call:

    dump_objs(http_request.query);

    ??

    ---
    Synchronet AlleyCat! BBS Lake Echo, NS Canada
  • From echicken@VERT/ECBBS to Mortifis on Fri Apr 10 08:55:00 2020
    Re: dump all object keys/values
    By: Mortifis to echicken on Fri Apr 10 2020 13:31:54

    function dump_objs(obj)
    {
    Object.keys(obj).forEach(function (e) {
    writeln(e + ': ' + JSON.stringify(obj[e]) + '<br>'); // run via an xjs script for html output
    });
    }

    // and a possible call:

    dump_objs(http_request.query);

    Nothing wrong with doing it that way, really. If you just want to dump an object without doing a lot of formatting, then DM's suggestion (along the lines) of:

    writeln(JSON.stringify(obj, null, 4));

    is sufficient. When doing quick debugging, this is often the way I go.

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com
    Synchronet electronic chicken bbs - bbs.electronicchicken.com
  • From Mortifis@VERT/ALLEYCAT to echicken on Fri Apr 10 13:18:00 2020
    Both have their merits so I utilize them both ... thank you both!

    ~Mortifis

    ---
    Synchronet AlleyCat! BBS Lake Echo, NS Canada