Jermuk
12/06/2024, 4:51 PMyaml
pipeline:
processors:
- javascript:
code: |
(() => {
let payload = benthos.v0_msg_as_structured();
console.log("begin");
// Step 1: Sort the array by the 'name' field numerically
payload.sort(function(a, b) {
return parseInt(a.name, 10) - parseInt(b.name, 10);
});
// Step 2: Convert each 'value' to its corresponding ASCII character
var chars = [];
for (var i = 0; i < payload.length; i++) {
chars.push(String.fromCharCode(payload[i].value));
}
console.log("end")
// Step 3: Join the characters into a single string
var resultString = chars.join('');
// Step 4: Assign the resulting string to a new field, e.g., 'converted_string'
let newPayload = {}
newPayload.converted_string = resultString;
benthos.v0_msg_set_structured(newPayload);
})();
https://cdn.discordapp.com/attachments/984082664678125578/1314635254962720900/image.png?ex=67547cfd&is=67532b7d&hm=52d9d35cf294c2ddfb11c2e8f022e7ff7f6e8a5097a7279f5e90a684af6e3afa&Jermuk
12/06/2024, 4:54 PMpipeline:
processors:
- javascript:
code: |
(() => {
let payload = benthos.v0_msg_as_structured();
console.log("add here your custom code")
benthos.v0_msg_set_structured(newPayload);
})();
Jermuk
12/06/2024, 4:55 PMBrian Pribe
12/06/2024, 4:57 PMLuke van Enkhuizen
12/06/2024, 5:40 PMJermuk
12/06/2024, 6:05 PMDanielH
12/06/2024, 7:57 PMDiederik
12/06/2024, 8:11 PMDiederik
12/07/2024, 11:18 AMJermuk
12/07/2024, 12:51 PMBrian Pribe
12/07/2024, 6:36 PMDanielH
12/07/2024, 7:37 PMDanielH
12/07/2024, 7:54 PMDenis
12/08/2024, 7:09 PMJermuk
12/10/2024, 5:20 PMJermuk
12/10/2024, 5:26 PMDiederik
12/10/2024, 6:03 PMDiederik
12/10/2024, 6:03 PMDiederik
12/10/2024, 8:20 PMJermuk
12/11/2024, 5:47 AM