Subj : dump all object keys/values
To : Mortifis
From : echicken
Date : Fri Apr 10 2020 12:55 pm
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.