Encoded json in function