Skip to content
Note-taking

icon picker
Serializing JSON in Bardeen

It's Extremely Difficult to Serialize a JSON Payload
My first tests with Bardeen’s HTTP GET and POST components left me struggling to be productive despite years of experience building API integrations. Bardeen, after all, is about achieving high productivity.
What seems to be missing when using the HTTP POST component is a simple way to serialize JSON objects the likes of which are typically required when you publish content to other systems.
This became painfully obvious when I created the Bardeen-to-Mem example. Like many APIs, the Mem API requires a simple JSON payload that looks like this:
{
"Content" : "The content...",
"createdAt" : "1994-11-05T08:15:30-05:00"
}
Crafting one of these in a Merge Text component seems simple enough until you actually build one. If you want to create a json payload and infuse some markdown to expose links more favorably or some date formatting, it’s even worse.
light
Bardeen needs a serializer component with templated text composition that allows you to blend other component outputs arbitrarily much the way a mail merge system uses handlebar variables.
The red arrows identify some of the really tricky points in the way the payload must be crafted.
CleanShot 2023-02-05 at 16.50.07@2x.png

Serializer Service

To [partially] overcome this challenge, I created a simple Google Apps Script Service. Here’s . You are free to use , however, I make no guarantees that it will be alive for the long run.
Instead of the madness shown above, I can sidestep much of the complexity by simply making an HTTP GET to serialize the data before sending it on to the API. Here’s a to learn how this works.

Simply compose a URL like this...

Call the serializer like this...

CleanShot 2023-02-05 at 17.14.56@2x.png
CleanShot 2023-02-05 at 17.16.50@2x.png

And get back a payload like this which is ready to POST to the api.
{
"title":"How to Loop Through the Array of JSON Objects in JavaScript",
"url":"https://www.microverse.org/blog/how-to-loop-through-the-array-of-json-objects"
}
If there’s a way to simplify this even more, don’t hesitate to do so and share how you did it. Hopefully, this post will be made obsolete by the folks at Bardeen.

©
2024
Global Technologies Corporation. All rights reserved.
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.