added working db functionality and conversion to JSON