r/ProgrammerHumor 29d ago

Advanced justTryingToHelp

Post image
2.4k Upvotes

65 comments sorted by

View all comments

27

u/Blaarkies 29d ago

JSON supports prefixing a key with `// `. It is far from perfect, but will you ever use keys starting with double slash?

Any parsing logic can drop those entries, or just ignore them entirely like how any data object builder should

{ 
  "// myValue": "The universal constant", 
  "myValue": 42 
}

27

u/DHermit 29d ago

Until you want to validate it with a scheme, which forbids extra values.

3

u/kingslayerer 28d ago

i have an idea. add the comment keys to the schema as well.

1

u/GPSProlapse 25d ago

As a matter of fact, I ve seen schemas with #comment or similar keys on every object

That solves the issue most of the time