https://qiita.com/Natukasi/items/20f8756e9e956684396c
の改良版。
readObjectはconstructorを通さないために、入力チェックを使用できない
writeReplace/readResolveを使用することで、constructorを通すことができる。
このサンプルには入れていないが、constructor内に入力チェックを仕込んでおく
return new Value2(this.name,this.price, this.val);
write replace
read resolve
v2-name:v2x v2.price:200v1-name:v1xv1-price:100