Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to save a JSON file of the output from Notion? #1

Open
profucius opened this issue Sep 28, 2023 · 2 comments
Open

How to save a JSON file of the output from Notion? #1

profucius opened this issue Sep 28, 2023 · 2 comments

Comments

@profucius
Copy link

Hello, I am using your community plugin, and have a question about how to set the fields for properly writing, and reading, the JSON output data from Notion into a JSON file on my local computer.

This is what I have so far, in order of actions:

  1. A manual trigger node.
  2. A Notion "Get Many" node. Output screenshots below:
    As a table:
    image
    As a JSON:
    image
  3. First issue: A JsonDatabase "Write to Database" node.
    Config:
    image
    Output error:
    image
  4. So then I change that node "Source JSON String" to be {{ JSON.stringify($json) }} instead.
    Config:
    image
    Output:
    image
    So far so good? Something seems off in the formatting though, it's not the same table format.
  5. A JsonDatabase "Read From Database" node.
    Config:
    image
    Output:
    image

This final output appears to match the written file. However, this is not the format that I need it to be in. I need it to match the output of the original Notion node, in a true table format.

What am I doing wrong here? I feel like it may be something related to javascripting the "Source JSON String", however I am still a novice at javascript and am scratching my head at how to proceed. Any help is welcome.

@profucius
Copy link
Author

Update: I figured it out. For anyone coming here with the same question, here is how I did it:

In the example above, where I take Notion output and save it to a JSON file, then read from that same JSON file.

Between the Notion node and the Write to JSON Database node, add a Item Lists node with Operation: Concatenate Items, Aggregate: All Item Data, Put Output in Field: data, Include: All Fields. Execute the flow and the JSON will be written to a valid format that other applications can read.

Then to read the JSON file, after the Read from JSON Database node, add another Item Lists node, this time with Operation: Split Out Items, Fields to Split Out: data, Include: No Other Fields. Execute the flow and the JSON will be read from the file into the exact same table format compared to the original Notion field.

I will leave this ticket open so that the dev has a chance to find and read this. I highly recommend that the dev add this into the documentation / readme for this plugin, so that future users will not struggle with this as I have for the past week. Thank you.

@andrigamerita
Copy link
Contributor

Hi @profucius, thanks for raising the issue. I believe the plugin is working as intended, but indeed the documentation is probably too lacking. I should add usage examples for this and other practical problems that can be solved by leveraging the plugin, but I will first have to further investigate the situation, since yours and other similar problems could be tackled without using all the extra blocks (which is good if possible, as less blocks mean a more understandable workflow).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants