TysonStarter
npm install tyson-starterTyson allows you to use TypeScript interfaces for JSON with enhanced features:
``bashInstall globally
npm install -g tyson
Usage
$3
`typescript
// test.interface.ts
export interface TsonTest {
title: string;
position: number;
type: string;
}
`$3
`typescript
// test.tyson or test.tson
import { TsonTest } from './test.interface';// Comments are allowed!
{: TsonTest
title: "sample title",
position: 0,
type: "sample type", // Inline comments work too
}
`$3
`bash
CLI usage
tyson test.tyson test.jsonWith options
tyson --input test.tyson --output test.json --interface test.interface.ts --interface-name TsonTest
`$3
`typescript
import { compileTyson, parseTyson } from 'tyson';// Compile a tyson file to JSON
compileTyson({
inputFile: 'test.tyson',
outputFile: 'test.json',
interfaceFile: 'test.interface.ts',
interfaceName: 'TsonTest'
});
// Or parse a tyson file and get the data
const data = parseTyson({
inputFile: 'test.tyson',
interfaceFile: 'test.interface.ts',
interfaceName: 'TsonTest'
});
`$3
The compiled JSON will look like:
`json
{
"title": "sample title",
"position": 0,
"type": "sample type"
}
``- Type Checking: Validates your JSON against TypeScript interfaces
- Comments: Include comments in your JSON files that won't appear in the output
- Unquoted Keys: No need to quote object keys
- TypeScript Integration: Seamlessly work with your existing TypeScript codebase
Contributions are welcome! Please feel free to submit a Pull Request.