3 ms·
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 schema
by jackjeff 5y ago
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.
- jestar_jokin 5y agoThere's libraries that let you define a schema programmatically, and then infer the types. https://github.com/sinclairzx81/typebox https://github.com/sinclairzx81/typebox
- yesbabyyes 5y ago> 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 https://github.com/YousefED/typescript-json-schema
- andyfleming 5y agoI like JSON5 for similar reasons. I specifically like the addition of comments, trailing commas, and keys without quotes.
- silon42 5y agoAlso needed is string concatenation. One line strings are very limiting.
- eitland 5y agoI'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.