Skip to content
Serializing JSON in Bardeen

icon picker
JSON Serializer

A Google Apps Script Serializer
You pass in arbitrary URL parameters; it returns a serialized payload using the same parameter names.

Input

https://<serializerEndpoint>?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

Output

{
"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"
}

Serializer Service Source Code

/*
***********************************************************
Bardeen R&D - Web Service
Copyright (c) 2023 by Global Technologies Corporation
ALL RIGHTS RESERVED
***********************************************************
*/

//
// GET service
//
function doGet(e) {

var params = e.parameters;

// *********************************************************
//
// serialize
//
// *********************************************************
if (params) {
var payload = serialize_(params);
/*
var json = {
"result": "200OK",
"payload" : payload
};
*/
var json = payload;
return ContentService.createTextOutput(JSON.stringify(json)).setMimeType(ContentService.MimeType.JSON);
}

}

//
// serialize
//
function serialize_(params)
{
var payload = {};
for(var key in params) {
for (var key1 in params[key]) {
payload[key] = params[key][key1]
}
}
return(payload);
}

©
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.