Open joeferner opened 8 years ago
@joeferner Could you please help me to know how to pass a javascript obj to the backend java program ?
Something like this.. I am trying this and getting undefined...
JavaScriptObj ->
remoteVar = {'remServer': '123'};
Javacode ->
public String jarunargs2(Object Obj){
String str = Obj.toString();
return "J Ran with args " + str;
}
Script call - >
test.jarunargs2(remoteVar, function(err,result){console.log("hello 2" + result )});
I am getting console as below.
hello 2undefined
Small finding... I found that the remoteVar has a value in JS. But after passing to the JAVA method its showing as null... and erroring out. TIA
For now your best bet is going to be converting that object into a string before passing it to java JSON.stringify
and then in Java you something like Jackson to parse it out.
Currently we return NULL for Javascript objects we can't convert (see https://github.com/joeferner/node-java/blob/master/src/utils.cpp#L367). It would be nice to be able to store those Javascript objects and retrieve them later.
I have created a branch here: https://github.com/joeferner/node-java/commit/732d26dc3606694cc279ddf4ecbdd60720b15afe
One problem is when do we delete the persisted object. https://github.com/joeferner/node-java/blob/store-javascript-objects-in-java/src/utils.cpp#L377