decode.js modified to check if json is stored prperly in db