Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to load document from JSON. #1849

Open
1 task done
jalvespinto opened this issue May 6, 2024 · 0 comments
Open
1 task done

Unable to load document from JSON. #1849

jalvespinto opened this issue May 6, 2024 · 0 comments
Labels
help wanted Extra attention is needed

Comments

@jalvespinto
Copy link

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

  • Item
  • Item: item

ORDERED LIST

  1. First
  2. Second: second

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? tks

@jalvespinto jalvespinto added the help wanted Extra attention is needed label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant