Monday, April 17, 2017

I just love JSON ;-)

I'm keeping "diary", so place where I put some thoughts and things I'm thankful.
I have my own program to keep it, but earlier I used to use Narrate.

And this was only cause to keep Narrate still on my phone*. 
So yesterday in night I exported all notes from Narrate to Google Drive.
I exported also file in which I keep diary items for my current program..

And thanks to this that this is JSON I was able to add those old notes from Narrate to my Diary ;-)

I needed just to add in my Python program this lines:


import json
diary = json.load(open("diary.json"))

and I had access to my file :-)
Latter I needed only to add new items to diary, sort it, and save it with:



json.dump(diary,open("new_diary.json","w+"))

With some binary format it would be also possible but more complicated.

With JSON it was easy :-)

As I wrote, I just love JSON ;-)

* - it is Nexus 6, and is becoming very, very slow, and I still hope that uninstalling not needed apps will make it faster ;-)



Similar postsbeta
Which language is fastest? ;-)
Why it isn't working???
Throw out 1 thing each day
My road to automation ;-)
How to detect clickbaits?

No comments:

Post a Comment