• dump all object keys/values

    From Mortifis@VERT/ALLEYCAT to All on Wed Apr 8 01:42:22 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 Wed Apr 8 00:53:42 2020
    Re: dump all object keys/valuesã By: Mortifis to All on Wed Apr 08 2020 01:42:22ãã Mo> 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 09:01:03 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 12:29:04 2020
    Re: dump all object keys/valuesã By: Mortifis to All on Wed Apr 08 2020 01:42 amãã Mo> 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 12:59:40 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ã >ã > Mo> 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.1øF, 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 15:25:17 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();ãã DM> JSON.stringify() does seem easier though:ãã DM> 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 13:31:54 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 12:55:29 2020
    Re: dump all object keys/valuesã By: Mortifis to echicken on Fri Apr 10 2020 13:31:54ãã Mo> function dump_objs(obj)ã Mo> {ã Mo> Object.keys(obj).forEach(function (e) {ã Mo> writeln(e + ': ' + JSON.stringify(obj[e]) + '<br>'); // run via an xjsã Mo> script for html outputã Mo> });ã Mo> }ãã Mo> // and a possible call:ãã Mo> 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 17:18:55 2020
    Both have their merits so I utilize them both ... thank you both!

    ~Mortifis

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