Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

JSONC. JSON with comments. And even if your favorite parser does not support it natively it’s not so hard to add with a very simple pre-lexer step.

JSON schemas exist and they’re ok for relatively simple things. For more complex cases I find myself wishing I could just turn Typescript into some kind of schema validation for JSON.



> For more complex cases I find myself wishing I could just turn Typescript into some kind of schema validation for JSON.

Not sure if this is what you're looking for, and whether it's powerful and expressive enough for your use case, but you can use typescript-json-schema¹ for this, and validate with eg ajv.

¹https://github.com/YousefED/typescript-json-schema


I like JSON5 for similar reasons. I specifically like the addition of comments, trailing commas, and keys without quotes.


I've struggled with this in Java recently and at first I used Jankson which supports the complete JSON5 spec, but later we figured out we could configure the standard Jackson JSON package to accept the things we actually need and actually use.


Also needed is string concatenation. One line strings are very limiting.


There's libraries that let you define a schema programmatically, and then infer the types.

https://github.com/sinclairzx81/typebox




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: