I am having trouble getting curl and Json (Node.js) to work when I in curl omit the "[ and ]" part of the JSON-RPC request params. I am using named parameters (i.e. an object, not an array).
This works:
curl -v -i POST -H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "method":"registerPerson", "params": ["{\"username\":\"morten10\",\"password\":\"mypass\"}"], "id":1 }' \
http://localhost:3000
However, when I omit the [" and ]" from the params it doesn't work:
curl -v -i POST -H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "method":"registerPerson", "params": {\"username\":\"morten10\",\"password\":\"mypass\"}, "id":1 }' \
http://localhost:3000
and Jayson gives this error message:
TypeError: First argument must be a string or Buffer
However, according to the JSON-RPC 2.0 specification and its examples, I should be able to exclude the "[ and ]" part from params when I use named parameters, as in this example:
--> {"jsonrpc": "2.0", "method": "subtract", "params": {"minuend": 42, "subtrahend": 23}, "id": 4}
<-- {"jsonrpc": "2.0", "result": 19, "id": 4}
What am I not getting?
Thanks!