add toJSON support to petal