Trying to use JOLT within Nifi to remove some fields from an API call, but having trouble getting it to work. Below is what is returned from the GitHub API:
[
{
"login": "sample name",
"id": "000001",
"node_id": "ID#",
"avatar_url": "RETURNED_URL",
"gravatar_id": "",
"url": "RETURNED_URL",
"html_url": "RETURNED_URL",
"followers_url": "RETURNED_URL",
"following_url": "RETURNED_URL",
"gists_url": "RETURNED_URL",
"starred_url": "RETURNED_URL",
"subscriptions_url": "RETURNED_URL",
"organizations_url": "RETURNED_URL",
"repos_url": "RETURNED_URL",
"events_url": "RETURNED_URL",
"received_events_url": "RETURNED_URL",
"type": "MEMBER_TYPE",
"site_admin": false
},
...
}
]
This is the JOLT Spec I have that is raising errors:
[
{
"operation": "remove",
"spec": {
"node_id":"",
"avatar_url":"",
"gravatar_id":"",
"url":"",
"html_url":"",
"followers_url": "",
"following_url": "",
"gists_url": "",
"starred_url": "",
"subscriptions_url": "",
"organizations_url": "",
"repos_url": "",
"events_url": "",
"received_events_url": "",
"type": "User",
"site_admin": false
}
}
]
There are about 70 results returned and i need it to do this for each one. None of them have a higher level key, so I thought it was that, but everything I've tried seems to throw a " is invalid because Specification not valid for the selected transformation
Instead or removing long list of fields, you can just pick the fields you need. In your case you can use Jolt Spec like this:
[
{
"operation": "shift",
"spec": {
"*": {
"login": "[&1].login",
"id": "[&1].id"
}
}
}
]
You can also use this jolt demo site to check yourself. This is how i checked it: