encapsulate functions in JSON