generate json from db