08-23-2022 06:44 AM
Hello, I have a feed coming from github which I need to get certain attributes but some of the items are being returned as arrays and some are being returned as objects!
Does anyone know how I can align the 2 types together to perform downstream tasks?
[
[{
"name": "stale.yml",
"path": ".github/workflows/stale.yml",
"sha": "xx",
"size": 425,
"url": "https://api.github.com/owners/Owner/repo/contents/.github/workflows/stale.yml?ref=BTRANCH",
"html_url": "https://github.com/Owner/repo/blob/BTRANCH/.github/workflows/stale.yml",
"git_url": "https://api.github.com/owners/Owner/repo/git/blobs/1234",
"download_url": "https://raw.githubusercontent.com/Owner/repo/BTRANCH/.github/workflows/stale.yml?token=xx",
"type": "file",
"_links": {
"self": "https://api.github.com/owners/Owner/repo/contents/.github/workflows/stale.yml?ref=BTRANCH",
"git": "https://api.github.com/owners/Owner/repo/git/blobs/1234",
"html": "https://github.com/Owner/repo/blob/BTRANCH/.github/workflows/stale.yml"
}
}],
{
"name": "pipeline",
"path": "BLAH/pipeline",
"sha": "1234",
"size": 40246,
"url": "https://api.github.com/owners/Owner/repo/contents/BLAH/pipeline?ref=BTRANCH",
"html_url": "https://github.com/Owner/repo/blob/BTRANCH/BLAH/pipeline",
"git_url": "https://api.github.com/owners/Owner/repo/git/blobs/1234",
"download_url": "https://raw.githubusercontent.com/Owner/repo/BTRANCH/BLAH/pipeline?token=xx",
"type": "file",
"content": "xx"
"encoding": "base64",
"_links": {
"self": "https://api.github.com/owners/Owner/repo/contents/BLAH/pipeline?ref=BTRANCH",
"git": "https://api.github.com/owners/Owner/repo/git/blobs/1234",
"html": "https://github.com/Owner/repo/blob/BTRANCH/BLAH/pipeline"
}
}
]
Solved! Go to Solution.
08-23-2022 07:54 AM
Try it this way:
08-23-2022 07:28 AM
Common problem - you can make sure that they will all be arrays by using the built-in function
sl.ensureArray()
08-23-2022 07:41 AM
I just get an error from using that
08-23-2022 07:54 AM
Try it this way:
08-23-2022 07:58 AM
wow, it was that easy!
I tried every other combination except for that one!
Thanks for your help