-
-
Notifications
You must be signed in to change notification settings - Fork 125
Description
Description
const jsonData = $convertToJSON[$$testing2];
function escapeNewlines(jsonString) {
return jsonString.replace(/\n/g, '\n');
}
const escapedJsonData = escapeNewlines(jsonData);
const parsedObject = JSON.parse(escapedJsonData);
const textValue = parsedObject.candidates[0].content.parts[0].text;
console.log(textValue);
Becomes:
const jsonData = {"candidates":[{"content":{"parts":[{"text":"!playMusic"}],"role":"model"},"finishReason":"STOP","avgLogprobs":-0.00043647171696648}],"usageMetadata":{"promptTokenCount":9181,"candidatesTokenCount":4,"totalTokenCount":9185,"promptTokensDetails":[{"modality":"TEXT","tokenCount":9181}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":4}]},"modelVersion":"gemini-2.0-flash"};
function escapeNewlines(jsonString) {
return jsonString.replace(/n/g, '
');
}
const escapedJsonData = escapeNewlines(jsonData);
const parsedObject = JSON.parse(escapedJsonData);
const textValue = parsedObject.candidates[0].content.parts[0].text;
console.log(textValue);
When written to a file.
jsonString.replace(//\n/g, \\\n);
And
jsonString.replace(/\n/g, "\n");
Also fail.
Steps to Reproduce
1.Add the code into a write file effect, can replace $$testing2 with a JSON object.
2.Write to file
3.pro... uh bad code in file.
Expected Behavior
Escape characters get replaced very aggressively and break code blocks.
Firebot Version
v5.63.2
Submitted By
oshimia
Created via Discord.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status