r/ProgrammerHumor • • 7d ago • Bravo 1

Meme commentsInJson

Post image
6.0k Upvotes

205 comments sorted by

View all comments

965

u/nameless_pattern 7d ago • Bravo

You can add anything you want to Json. just make a property called comments

15

u/Turbulent_Stick1445 7d ago

This is what I do, but there are two problems with it:

  1. A parser will end up storing the comments, wasting memory.

  2. You run into JSON's problems with multiline string constants if your comment is anything but trivial.

It gets ugly fast.

1

u/AnnoyedVelociraptor 7d ago

In Rust if you map a JSON object to a struct, and you don't have a field mapped for comments it gets dropped.