Fast JSON powered by TypeScript
import{schema}from"ftson";import{ArbitraryType}from"./src/types/ArbitraryType";exportconststringify={"./src/generated/1.ts": {stringify1: schema<ArbitraryType>(/* global config */)({// config for the typekeyOrder: ["b","a"],// config for a nested typefields: {b: {fields: {c: {keyOrder: ["d","e"]}}}},}),},};npx ftsonA file like the one below will be generated at ./src/generated/1.ts:
import{ArbitraryType}from"../types/ArbitraryType";exportfunctionstringify1(input: ArbitraryType): string{return`{"b":${/* ... fast stringify function */},"a":${input.a}}`;}It may require runtime dependencies such as @ftson/escape.
As you may have noticed, the heavy stringify function generator is not needed at runtime!
Work in Progress, incomplete.