Converting JSON value to dictionary

Hello, I am attempting to convert this into Appian values, but I am having trouble. 

What would be the best way to convert this?

Here is the raw response from an API:

{"response":"{\"requestId\":\"123456\",\"status\":0,\"description\":\"Success.\",\"response\":{\"transactionId\":\"12241094986\",\"payfoneAlias\":\"432432424\",\"phoneNumber\":\"324324324234\",\"lineType\":\"Mobile\",\"carrier\":\"T-Mobile USA\",\"countryCode\":\"US\",\"statusIndex\":\"51\",\"isBaselined\":true,\"score\":1000,\"phoneNumberVelocity\":0,\"portVelocity\":0,\"payfoneTenure\":{\"minimumDate\":\"2024-08-05T23:59:59.000Z\"},\"phoneNumberTenure\":{\"minimumDate\":\"2024-08-05T23:59:59.000Z\"}}}"}

a!localVariables(
  local!callService: rule!score(
    customerPhoneNumber: ri!phoneNumber,
    consentStatus: ri!consentStatus
  ).result.body,
  local!jsonArray: a!toJson(
    value: local!callService,
    removeNullOrEmptyFields: true
  ),
  local!jsonArrays: a!fromJson(local!jsonArray),
  local!jsonArrays
)

Here is the result after testing above code:

[response:{"requestId":"123456","status":0,"description":"Success.","response":{"transactionId":"12241091363","payfoneAlias":"432432424","phoneNumber":"324324324234","lineType":"Mobile","carrier":"T-Mobile USA","countryCode":"US","statusIndex":"51","isBaselined":true,"score":1000,"phoneNumberVelocity":0,"portVelocity":0,"payfoneTenure":{"minimumDate":"2024-08-05T23:59:59.000Z"},"phoneNumberTenure":{"minimumDate":"2024-08-05T23:59:59.000Z"}}}]

  Discussion posts and replies are publicly visible

Parents Reply
  • 0
    Certified Lead Developer
    in reply to cindyl5142

    "body" is not under "local!callService" but under ".result".

    Therefore the proper syntax would be a!fromJson(local!callService.result.body) by what I can see here.
    (Or local!callService.result.body.CensoredResponse even - due to your redactions I'm slightly unclear what the data structure is on that last layer down.)

    The usual way to troubleshoot this would be to start with your response (local!callService) and return just that in your rule, then add ".result" to that and make sure it still works, then add ".body" to that and make sure it still works (and looks like valid JSON), then wrap that in a!fromJson() - when you try to bang it all out at once, you're setting yourself up for failure because the issue could be anywhere in those several successive logical steps and it's hard to tell which.

Children