Parse Collection

Summary

I’m building an integration where items in Pocket are sent to a Notion database as items. I need to extract the tags from Pocket and add them as a comma-separated string to a text parameter called “tags” in Notion. I’m having trouble figuring out how to convert the Pocket tags, which are stored as a dictionary in the collection, into the required string format. I’ve tried using parsing modules, regex, and iteration, but I’m missing something. Can you help me extract the tags from the Pocket collection and format them as a string in the format “to_read, web3” for use in Notion?

Acording to ChatGPT here’s the solution if I were to write this in a python script:

tags = pocket_collection['tags']  # Extract the tags field from the Pocket collection
tag_names = list(tags.keys())  # Get a list of all the tag names
formatted_tags = ", ".join(tag_names)  # Concatenate the tag names into a single string

JSON return from Pocket

[
    {
        "tags": {
            "to_read": {
                "item_id": "3775234885",
                "tag": "to_read"
            },
            "web3": {
                "item_id": "3775234885",
                "tag": "web3"
            }
        }
    }
]

Screenshots:



Screenshot 2022-12-29 081023

ChatGPT Log

Hey @shaiss ,
not sure if I am getting your question right but in order to get the tags out of that JSON structure you can use text aggregator as seen on the screenshot below.

I am attaching also the blueprint which you can import into your project. Hope this helps and don’t hesitate to ask if needed.
Parsing tags blueprint.json (3.7 KB)

Cheers.
Jan from Make

TY @Jan_Knettig !! the caveat is that those tags are dynamic and therefore I have no idea if it’ll be 1 tag or 20 nor what they’ll be. SO my goal is to convert them from the array/collection to a csv format so that notion can then use it.

Goal:
JSON>CSV>Notion Field

Hi @shaiss , ok, I understand your problem now. Not sure whether I have something worthy for you, but this regex can be used to parse the values of tags:

(?<=tag\": \").+(?=\")

So, using a combination of text parser and text aggregator I was able to construct the string you need. However, not sure whether you will be able to use that in your scenario.

Attaching the blueprint.
Parsing tags blueprint 2.json (6.3 KB)

Cheers.

1 Like

Hi @Jan_Knettig! I seem to be able to get it to work if I use the json in the “text parser” module. however, if I reference the field coming from pocket “tags” it get’s an error “Collection can’t be converted to text for parameter ‘text’.”:


Raw JSON

    {
        "tags": {
            "to_read": {
                "item_id": "3775234885",
                "tag": "to_read"
            },
            "web3": {
                "item_id": "3775234885",
                "tag": "web3"
            },
            "web4": {
                "item_id": "3775234885",
                "tag": "web4"
            },
            "web5": {
                "item_id": "3775234885",
                "tag": "web5"
            },
            "web6": {
                "item_id": "3775234885",
                "tag": "web6"
            },
            "web7": {
                "item_id": "3775234885",
                "tag": "web7"
            }
}
}

In the make UI
image
expanding that out:
image

Any ideas? Or could there be a bug, as the output from pocket, doesn’t have the blank 1st entry:
image

I used the “transform to Json module” on the tags collection and now get this from the json:

{"read-later":{"item_id":"3776227804","tag":"read-later"},"recipes":{"item_id":"3776227804","tag":"recipes"},"to_read":{"item_id":"3776227804","tag":"to_read"},"web3":{"item_id":"3776227804","tag":"web3"},"work_followup":{"item_id":"3776227804","tag":"work_followup"}}


I tried "tag": "([^"]+)" for the match pattern, but no luck.