I have the following scenario: I was hoping that I can somehow set a toJSON method on the property “x” in the defineProperty call, but that didn’t work. Any help would be appreciated. Answer This is what worked for me: Note test is not a prototype definition and enumerable has to be set to true. I tested the above working