build json from mongodb to javascript