Search code examples
jsonapache-nifijolt

Extract value from specific flow file content in Nifi


I have a flow which runs few scripts and provide an output like below:

{
  "token_type": "Bearer",
  "expires_in": "3599",
  "ext_expires_in": "3599",
  "expires_on": "1696064476",
  "not_before": "1696060576",
  "resource": "https://management.com/",
  "access_token": "kVSiwZy0pwnXRbakA98b_pxQRHyjdF5jkXBcGtRdPtGlEn8GbvplFQM_8PtDKLdvHydhU3gRSDd_t22OfN3wiGyY9Rfiw3SL6sR4VdPseaOerrQq5Hx8yaqZQkbYL1OfsNieTUV31WM1ymxhbYLkgxjbao2EpzC1XbZX_6jnjPnA66lZIBw"
}
https://crtyu.net/ars/98d3-99c48f0c0165?sv=2018-03-28&sr=b&sig=6nakoARUgAhttps&st=2023-09-30T07%3A57%3A02Z&se=2023-09-30T2A02%3A02Z&sp
{
  "url": "https://ccswindows.net/armrep/fda8053c-2-466d-98d3-99c48f0c0165?sv=2018-03-28&sr=b&sig=6nakgAJ6f2%2BL1Lhdf%2BcksTxefYX7TDpf53%2B4UXo%3D&spr=https&st=2023-09-30T07%3A57%3A02Z&se=2023-09-30T20%3A02=r",
  "subscription": "c544",
  "is_billing_completed": true,
  "from_date": "2023-03-01",
  "to_date": "2023-03-02",
  "cost_type": "AmortiCost"
}

Kafka topic for producer is amortized_billing Cost Queued

from this response I only want the 'url' which I need to invoke to generate a file. Need help in fetching the url as an attribute.


Solution

  • You can add a JoltTransformJSON processor along with the following specification :

    [
      {
        "operation": "shift",
        "spec": {
          "url": ""
        }
      }
    ]
    

    which will extract url value only.