Adds (and tests) JSON export functionality