Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Storing text from textview as JSON String
-
Hi Friends,
I just want to take input from TextView Or Any Text Clip And Store It In As A JSON String, including newlines and tabs. Lot of scripts teach how to strip escape characters, i want the program to insert them automatically.It is taking me a lot of time to insert \n and \t manually.
I ultimately want to store a bunch recipes in JSON file, as simple dictionary.
Thank you. Ram -
json.dump
can be used to write alist
ordict
into a JSON file, andjson.load
to read a JSON file. Thejson
library automatically escapes and unespaces all strings when writing/reading, that way you don't need to do any of that by hand. -
Thank You @dgelessus ,
I have been sitting and editing JSON data files manually, inserting \n \b..
:)