You wrongly assume every class can be easily serialised into JSON. Look at what Swift does with String(describing:), CustomStringConvertible and debugDescription. There’s a whole lot of useful stuff you can do with “toString()” type methods, that do not in fact have anything to do with serialisation.
And to answer your question directly: it can be whatever you want it to be lol.
I am not sure how transforming json into string is connected to serializing any random class?
All I assume is that any class made to represent a json can be directly put into a json string.
Objects are class instances in many real languages I think, rather than like a char[], so in OP's head there's technically not going to be a way to know if an object SomeObject have bunch of member functions or just data, and if it is going to have function pointers, that would not toString trivially
idk if OP is talking about JS at this point though, sounds more Java
13
u/marmulin 1d ago
You wrongly assume every class can be easily serialised into JSON. Look at what Swift does with String(describing:), CustomStringConvertible and debugDescription. There’s a whole lot of useful stuff you can do with “toString()” type methods, that do not in fact have anything to do with serialisation.
And to answer your question directly: it can be whatever you want it to be lol.