Convert data from SQL DB into a JSON document