Currently, I am facing a challenge with serializing my business objects into JSON for use in a JavaScript application. My main concern is maintaining the purity of my business objects by keeping them unaware of data access or persistence. Introducing a toJSON() function directly within the objects seems counterintuitive to this goal. However, utilizing an external object for serialization is not feasible due to private instance variables.
Could it be possible that my current approach is incorrect?