java/groovy jsonrpc

+2 votes

hello,

i'm currently trying to create an open asset via jsonrpc; if i'm creating a default asset i'm happy; but with the open-parameter i have a problem; neither of the following code is functional

//Using when the param order is known
// JSONArray params = new JSONArray();
params.add(address)
if (isOpen == false) {
    params.add(assetName)
}
else {
    params.add('{"name":"asset5","open":true}')
}
params.add(quantity)

// Using with namend parameters
// The required named parameters to pass
Map<String,Object> params = new HashMap<String,Object>();
params.put("address", address);
params.put("name","asset7")
params.put("open", true)
params.put("qty", quantity)
i'm using the jars from http://software.dzhuvinov.com/json-rpc-2.0-base.html
 
can someone help?
thanks and regards
thomas
asked Sep 23, 2016 by tkdp

1 Answer

+1 vote

You need to pass the name and open parameters together as an object, presumably using a HashMap, in place of the string here:

params.add('{"name":"asset5","open":true}')
answered Sep 23, 2016 by MultiChain
and which key should i use?

Map<String,Object> params = new HashMap<String,Object>();
params.put("address", address);
params.put(????, '{"name":"asset5","open":true}')
params.put("qty", quantity)

i tried this with the key = "params" but were not successful

thomas
Based on what you've written I'm guessing it's something like this:

JSONArray params = new JSONArray();

... params before name/open ...

Map<String,Object> nameopen = new HashMap<String,Object>();
nameopen.put("name", "asset5");
nameopen.put("open", true);
params.add(nameopen);

... params after name/open ...
it's functional ==> thank you!!!!
...