Using insert details JSON who to accept Int or float in windows

+2 votes
Using the following API, how do you setup int and float JSON key:value pairs?

API command: issue "someaddress" "somename" 1 0.0001 0 {\"someInt\":1,\"somefloat\":1.0}

When I try, I get the following error:

error code: -1
error message:
value is type int, expected str
asked Oct 23, 2018 by rkottke

1 Answer

+2 votes
The problem here is how you are representing the final parameter – it needs to be in double quotes as well.
answered Oct 24, 2018 by MultiChain
Nah, I tried that: multichain-cli chain7 issue "1V22KWYirJmWUHbwvjedZTW1rJVqrmHkHhPqGf" "somename" 1 0.0001 0 \"{\"someInt\":1,\"somefloat\":1.0}\"

This gives: error: Error parsing JSON:"{"someInt":1,"somefloat":1.0}"

The only way I can get it to work is by adding quotes to the integer and float:
multichain-cli chain7 issue "1V22KWYirJmWUHbwvjedZTW1rJVqrmHkHhPqGf" "somename" 1 0.0001 0 {\"someInt\":\"1\",\"somefloat\":\"1.0\"}

Doing this makes the JSON object something other than what it was intended and causes the developer to make allowance for casting types.
You need regular quotes (without the slash) around parameters passed on the Windows command line, and then slashed quotes within the parameters. So the last parameter should be:
 
"{\"someInt\":1,\"somefloat\":1.0}"
Nope, tried that also:
multichain-cli chain7 issue "1V22KWYirJmWUHbwvjedZTW1rJVqrmHkHhPqGf" "somename2" 1 0.0001 0 "{\"someInt\":1,\"somefloat\":1.0}"
Get the following error:
error code: -1
error message:
value is type int, expected str
OK, so the other problem is that only MultiChain 2.0 (in alpha) allows any JSON structure for asset metadata - MultiChain 1.0 allows string values only. Apologies that I forgot about that.
Actually, that's great news and thanks so much.  I was going crazy with this one.  I'll look forward to the 2.0 release!
...