Display/use escaped characters like "\n" for line break in document editor
I have text fields that may contain "invisible" special characters like a line-break, which is commonly represented as "\n". Another example might be "\t" for tab, but there may also be other invisible unicode characters.
I would like to be able to edit/save documents in MongoDB Compass that contain such characters.
The current behaviour is that these characters are completely lost when the document is in edit mode and saved (updated). Manually inserting "\n" in a text field does not insert a line break, but literally a backslash + "n".
Example document:
{
"_id": "***",
"text": "Hello,\n\nThis is my message."
}
If I edit this document, e.g. changing the "." at the end of the text to a "!" it would be saved as "Hello,This is my message!"
-
AdminMassimiliano (Admin, MongoDB) commented
In Compass 1.20+ you can do this by switching to JSON Mode (see attachment).