Sunday, December 10, 2023

Hanson: JSON for Humans

 timjansen/hanson: JSON for Humans - with unquoted identifiers, multi-line strings and comments @GitHub

HanSON is an extension of JSON that fixes its shortcomings with a few simple additions to the JSON spec:

  • quotes for strings are optional if they follow JavaScript identifier rules.
  • you can alternatively use backticks, as in ES6's template string literal, as quotes for strings. A backtick-quoted string may span several lines and you are not required to escape regular quote characters, only backticks. Backslashes still need to be escaped, and all other backslash-escape sequences work like in regular JSON.
  • for single-line strings, single quotes ('') are supported in addition to double quotes ("")
  • you can use JavaScript comments, both single line (//) and multi-line comments (/* */), in all places where JSON allows whitespace.
  • Commas after the last list element or object property will be ignored.

Example HanSON

  listName: "Sesame Street Monsters", // note that listName needs no quotes
  content: [
      name: "Cookie Monster",
      /* Note the template quotes and unescaped regular quotes in the next string */
      background: `Cookie Monster used to be a
monster that ate everything, especially cookies.
These days he is forced to eat "healthy" food.`
    }, {
      // You can single-quote strings too:
      name: 'Herry Monster',
      background: `Herry Monster is a furry blue monster with a purple nose.
He's mostly retired today.`
    },    // don't worry, the trailing comma will be ignored

used here: gfxfundamentals/webgpufundamentals @GitHub

and here: gfxfundamentals/webgl-fundamentals: WebGL lessons that start with the basics

PDF generating tools

CLI / EXE tool:

DotNet tools

hardkoded/puppeteer-sharp: Headless Chrome .NET API => Generate PDF Files

MIT license

alternative tool to Puppeteer, developed by Microsoft
Fast and reliable end-to-end testing for modern web apps | Playwright

alternative semi-free tool

QuestPDF/QuestPDF: QuestPDF is a modern open-source .NET library for PDF document generation. Offering comprehensive layout engine powered by concise and discoverable C# Fluent API. Easily generate PDF reports, invoices, exports, etc.

interesting dual-license: free for business with revenue < $1M, otherwise paid

QuestPDF/ at main · QuestPDF/QuestPDF

The Easiest Way to Create PDFs in .NET - YouTube

a good JavaScript tool, with MIT license, generating PDF directly, without converting from HTML

foliojs/pdfkit: A JavaScript PDF generation library for Node and the browser