[Tutor] Best Practices with JSON Data

Alan Gauld alan.gauld at yahoo.co.uk
Sun May 8 19:46:47 EDT 2016


On 08/05/16 14:07, Hunter Jozwiak wrote:

> I am intending to start work on a Python program that will allow me to
> better manage my Digital Ocean droplets, due to the fact that the website
> can be at times a bit overkill for some of the basic tasks I want to do. 

OK, but I have absolutely no idea what Digital ocean is, nor
what a droplet is. So we may need more background later.

> have a question in regards to the best practice of manipulating JSON data.
> Would it be better to just parse the data that Digital Ocean returns as a
> result of doing such things as a Get command, or would it be better to
> create a Droplet class with functionality specific to Droplets? 

That really depends on what you plan on doing.
If you need to do a lot of processing of the data or using it
in interaction with other objects/data then a class might make
sense.  But if you just want to collect data into a data store
(file or dbms) or filter out some reports then just reading
the JSON is probably fine.

> am asking is due to the fact that I haven't found any good information on
> the topic, so am not sure of the Pythonic or standard way to do this.

There's probably no information about droplets except on the Digital
Ocean forums (assuming such things exist!). But the general approach
in Python is to do whatever makes most sense. Don't over complicate
things but don't over simplify either. It all depends on what you
need to do.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list