How can I retrieve a boolean value from JSON using JavaScript and Spin?

I have a service task which calls a REST API; the API is returning the following JSON:

{
    "success": true,
    "message": null,
    "details": [],
    "errors": [],
    "transactions": []
}

The service task has a JavaScript output parameter to process the JSON output:

var statusCode = connector.getVariable("statusCode");
if (statusCode != 200) {
    throw new Error(connector.getVariable("response"));
}
else {
    var output = S(connector.getVariable("response"));
    output.prop("success").value==true;    // Problem line
}

I have sent the output to a process variable and confirmed that it contains the JSON above. However, I cannot get this output to ever register as true for the subsequent forking of the process. I have tried all of the following:

output.prop("success");
output.prop("success").value;
output.prop("success").value==true;
output.prop("success").value===true;
output.prop("success").value=="true";

Can anyone help with getting this right?

Hey @Ettery,

Try it like this:

Cheers,
Thorben

Thank you, @thorben, my new code looks like this and is working well.

var statusCode = connector.getVariable("statusCode");
if (statusCode != 200) {
    throw new Error(connector.getVariable("response"));
}
else {
    var output = S(connector.getVariable("response"), "application/json");
    output .prop("success").boolValue();
} 

The Java code for org.camunda.spin.impl.json.jackson.JacksonJsonNode looks as if I should be able to just use .value() instead of .boolValue() - is that the case?

Yes, #value should be fine as well.