Skip to content

Instantly share code, notes, and snippets.

@davesnowdon
davesnowdon / json_serialisation.py
Last active December 13, 2015 22:49
Serialise custom python objects to/from JSON using 2 helper functions in the classes to handle the conversion for each class.
import sys
import inspect
import json
'''
Functions for clients to call to serialise/unserialise from strings and files
Idea taken from http://getpython3.com/diveintopython3/serializing.html
and generalised to allow helper functions to be part of the custom classes
and avoid case statements