use NewEncoder for json marshaling