use a json.Encoder instead of Marshall