Cleans the raw string by extracting the JSON content between the first { and the last }.
Also replaces escaped new line characters and escaped quotes.
Parameters
raw_string: string
The raw string to be cleaned.
Returns string
A cleaned JSON string.
Example
constcleaned_string = clean_json_string('Some text before { "key": "value" } some text after'); console.log(cleaned_string); // Outputs: '{ "key": "value" }'
Cleans the raw string by extracting the JSON content between the first
{
and the last}
. Also replaces escaped new line characters and escaped quotes.