moved json conversion to the api view to keep the model function flexible