implement toJSON and parse