Imagine creating a class called Rectangle with private fields like width and height, initializing them in the constructor. However, when calling JSON.stringify on an instance of this class, it returns an empty object without including the private members.
Is there a simpler way to make private fields visible in the JSON output without having to create a toJSON method for each member? It seems tedious to manually include every private field in the toJSON method.