You won't need to JSON parse the results of an inline roll. The example in the wiki for sending dice expressions is using /roll (I should really expand that page...), for which the API receives the result as a JSON string. With inline rolls, you don't need to deal with the JSON as the roll data is all stored as an object in the inlinerolls property. Try both of these and look at the difference in the output: sendChat('', '/roll 1d4+3',function(msg){ log(msg); });
sendChat('', '[[1d4+3]]',function(msg){ log(msg); }); The first one will have a msg.type of 'rollresult' and the msg.content will be a string which is a JSON encoded object: [
{
"who": "",
"type": " rollresult ",
"content": " {\"type\":\"V\",\"rolls\":[{\"type\":\"R\",\"dice\":1,\"sides\":4,\"mods\":{},\"results\":[{\"v\":1}]},{\"type\":\"M\",\"expr\":\"+3\"}],\"resultType\":\"sum\",\"total\":4} ",
"playerid": "API",
"avatar": false,
"inlinerolls": {
},
"origRoll": "1d4+3",
"signature": "7068d6aeb53e7cda5f2143b3b77153cfc9f2366d9b7917d4febb280086e87c4efe2cdaaa2b45dd0e8fdb45dd9d2741e9909e9b41a559653f56af5073404d5c9c",
"_fbid": "-Jnbf4Mgdcb-t3SQVnmO"
}
] The second one will have a msg.type of 'general' and the mesg.content will be the string '$[[1]]'. Additionally, it will have a msg.inlinerolls that contains the details of the roll. The $[[1]] is a placeholder for where the roll should go, the 1 is the index into msg.inlinerolls: [
{
"who": "",
"type": " general ",
"content": " $[[1]] ",
"playerid": "API",
"avatar": false,
"inlinerolls": {
"1": {
"expression": "1d4+3",
"results": {
"type": "V",
"rolls": [
{
"type": "R",
"dice": 1,
"sides": 4,
"mods": {
},
"results": [
{
"v": 1
}
]
},
{
"type": "M",
"expr": "+3"
}
],
"resultType": "sum",
"total": 4
},
"signature": "3c61313b9f7e929f90ef212b4849ff0e364f1ffe02d287469a5e13dca58e52bb38d22f70ff9b2d8cc1d1a71d53f8a82d06f5119064c65b680197e05b475a5785",
"rollid": "-Jnbf4MmCx_MIb55wopD"
}
}
}
]
(BTW, when you run this, the inline rolls returns much faster so actually appears in the log sooner, at least for me.)