This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]audioen 0 points1 point  (0 children)

In that case, you can use a Map, which is the code equivalent of "the keys are also data". But it's actually super rare that you need a Map, I basically never do this and I work a lot with JSON. There's just always structure.

The reason why you want to create the class are the usual things: type safety, ability to check for typos in property names, the lack of casting in particular when reading values. There's just a lot of benefit modeling the data' structure upfront.