Fast JSON powered by TypeScript
import { schema } from "ftson";
import { ArbitraryType } from "./src/types/ArbitraryType";
export const stringify = {
"./src/generated/1.ts": {
stringify1: schema<ArbitraryType>(/* global config */)({
// config for the type
keyOrder: ["b", "a"],
// config for a nested type
fields: { 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";
export function stringify1(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.