Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript: How to print objects in Jrunscript?

Jrunscript has a 'print' function. Yet it does not print anything useful about objects. For example:

js> var obj = {one:1, two:2}

When evaluating object Jrunscript outputs just that:

js> obj  

[object Object]

And 'print' is no good as well:

js> print(obj)

[object Object]js> 

What Jrunscript functions can be used to print object structure?

like image 955
dokondr Avatar asked Nov 05 '22 05:11

dokondr


1 Answers

use rhino+env.js:

http://www.envjs.com/

sample:

load('env.rhino.1.2.js');
var t1 = {// 10
    "1" : {
        "q0" : "q1",
    },
    "0" : {
        "q1" : "q2"
    }
};
print(JSON.stringify(t1));

Of course you get other useful stuff, but it helps you for the moment

like image 166
Sombriks Avatar answered Nov 07 '22 20:11

Sombriks