I am faced with the challenge of converting between two classes called MyObject
and MyObjectJSON
, which have helper methods to assist in the conversion process: myObj.toJSON()
and MyObject.fromJSON()
.
Currently, I have instances of these classes represented in two different constructs that need to be converted back and forth:
- A mapping of
MyObject
instances where the keys are based on theirid
property:{ [id: number]: MyObject }
- A list containing instances of
MyObjectJSON
:MyObjectJSON[]
Seeking guidance on how to efficiently convert between these two structures using the lodash
library.