json2typescript icon indicating copy to clipboard operation
json2typescript copied to clipboard

Parent data in custom converter

Open andreas-aeschlimann opened this issue 5 years ago • 2 comments

As of now, the JsonCustomConvert interface has the methods serialize(data: T): any and deserialize(data: any): T.

In some cases, the (de-)serialization might be dependent on the parent's object values. We could add an optional parameter parentData?: any in both methods that contains the parent data (object) if it exists, undefined otherwise.

andreas-aeschlimann avatar Jun 01 '20 19:06 andreas-aeschlimann

This is exactly the feature I currently need and that's why I came across this issue.

Would be great if a context could be passed. Then this could be extended in the future with other useful data.

srn271 avatar Oct 07 '22 10:10 srn271

A reference to the jsonConvert instance would be also nice. In some use cases I needed access to it in order to manually (de)serialize something.

andreas-aeschlimann avatar Dec 18 '22 21:12 andreas-aeschlimann