serialize json in api