Skip to main content
August 5, 2025
Question

Converting JSON value to dictionary

  • August 5, 2025
  • 10 replies
  • 0 views

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"}}}]

10 replies

mikes0011
Brainy
August 5, 2025

The raw response there doesn't look like standard JSON per se - at the very least it looks as if it's been "nested" in a way that causes most of the double quotes to be "backslash escaped".  I'm guessing you need to call a!fromJson() on the initial response and then call a!fromJson() again on the ".response" property of the first call.

mikes0011
Brainy
August 5, 2025

This seems to work fine:

August 5, 2025

Hmm :(