toJSON/fromJSON for svm