char/fjson

friendly JSON implementation in TypeScript

git clone https://git.t4t.associates/char/fjson

Charlotte Somrestructurebb03820

main
691 B23 linesraw

fjson

config format: "friendly JSON" for TypeScript :D

it is essentially JSON, except:

  • the root of a document may be an "implicit map" (i.e. imaginary { <doc> })
  • simple ASCII identifier keys may be unquoted in maps (e.g. { hello: "world" })
  • trailing commas are permitted in maps and arrays
  • commas can be replaced by newlines in maps and arrays
  • strings may be single-quoted
  • documents may contain // comments
import * as fJSON from "@char/fjson";

const value = fJSON.parse("name: 'demo'\nactive: true");
// => { name: "demo", active: true }

fJSON.stringify({ name: "demo", targets: ["linux", "macos"] });
// => 'name: "demo"\ntargets: ["linux", "macos"]'
1# fjson
2
3config format: "friendly JSON" for TypeScript :D
4
5it is essentially JSON, except:
6
7- the root of a document may be an "implicit map" (i.e. imaginary `{ <doc> }`)
8- simple ASCII identifier keys may be unquoted in maps (e.g.
9  `{ hello: "world" }`)
10- trailing commas are permitted in maps and arrays
11- commas can be replaced by newlines in maps and arrays
12- strings may be single-quoted
13- documents may contain `// comments`
14
15```ts
16import * as fJSON from "@char/fjson";
17
18const value = fJSON.parse("name: 'demo'\nactive: true");
19// => { name: "demo", active: true }
20
21fJSON.stringify({ name: "demo", targets: ["linux", "macos"] });
22// => 'name: "demo"\ntargets: ["linux", "macos"]'
23```