Skip to main content
February 7, 2024
Question

how to extract secondary json from the http response

  • February 7, 2024
  • 1 reply
  • 0 views

hi, 

my json response is as follows : 

Body={…………

message={role=user, function_call={name=fn_test ,arguments={ "annotations": [ { "originalText": “text1”, "annotation": { "classification": "Rule", "rule": true } }, 

{ "originalText": “text2”, "annotation": { "classification": "Rule", "rule": true } }

json to Appian shows like this.

I was able to traverse until arguments using httpresponse but cannot pull anything inside annotations ,wanted to extract every ( original text, classification and rule) and store it as records in database.Any ideas appreciated.

 

    1 reply

    abhayd3663
    February 7, 2024

      local!requestBody: a!fromJson(http!request.body),
      local!nextLevel: a!forEach(
        items: local!requestBody,
        expression: fv!item.message.name.arguments
      )

    After converting JSON to Appian value using a!fromJson(), you can traverse by using dot notation.