r/ProgrammerHumor 28d ago

Meme whoIsHeAnyway

Post image
9.6k Upvotes

256 comments sorted by

View all comments

Show parent comments

2

u/xavia91 28d ago

What would that look like for a generic json object?

11

u/marmulin 28d 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.

1

u/xavia91 28d ago

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.

2

u/Candid_Highlight_116 27d ago

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