Support user-defined classes
brillout opened this issue · 0 comments
brillout commented
Allow the user to extend json-serializer
with user-defined classes with custom (de-)serialization.
AFAICT it should be fairly easy to implement. PR welcome.
Currently json-serializer
behaves like JSON.stringify()
/JSON.parse()
regarding user-defined classes:
class MyClass {
prop = 42
}
const obj = new MyClass()
console.log(obj) // MyClass { prop: 42 }
console.log(obj instanceof MyClass) // true
const copy = JSON.parse(JSON.stringify(obj))
console.log(copy) // { prop: 42 }
console.log(copy instanceof MyClass) // false