Unable to load document from JSON. #1942
jalvespinto
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is there an existing issue for this?
The question
I have create this simple text to see how
jsonEncode(_controller.document.toDelta().toJson())
. This was the text in markdown:TITLE
CATEGORY: Category
LIST
ORDERED LIST
This is what
jsonEncode(_controller.document.toDelta().toJson())
returned:[{"insert":"Title\n","attributes":{"header":3}},{"insert":"CATEGORY: ","attributes":{"bold":true}},{"insert":"Category\n\n"},{"insert":"LIST","attributes":{"bold":true}},{"insert":"\n"},{"insert":"Item\n","attributes":{"list":"bullet"}},{"insert":"Item:","attributes":{"list":"bullet","bold":true}},{"insert":" item\n","attributes":{"list":"bullet"}},{"insert":"\n"},{"insert":"ORDERED LIST","attributes":{"bold":true}},{"insert":"\n"},{"insert":"First\n","attributes":{"list":"ordered"}},{"insert":"Second: ","attributes":{"list":"ordered","bold":true}},{"insert":"second\n","attributes":{"list":"ordered"}}]
Now, when I try to get a Document from it (using
Document.fromJson(jsonDecode(jsonEncode(_controller.document.toDelta().toJson())))
it doesn't work because it has\n
instead of\\n
and because there is no{"insert": "\\n"}
at the end (or I need to append 'r' in front of the string to denoted as a raw string. How should I deal with this? tksBeta Was this translation helpful? Give feedback.
All reactions