https://github.com/lq782655835/json2ts
automatically generate typescript definition file from url
https://github.com/lq782655835/json2ts
json2ts tools typescript
Last synced: 2 months ago
JSON representation
automatically generate typescript definition file from url
- Host: GitHub
- URL: https://github.com/lq782655835/json2ts
- Owner: lq782655835
- Created: 2019-01-24T08:49:42.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-01-17T15:07:23.000Z (over 5 years ago)
- Last Synced: 2025-01-22T17:44:55.376Z (4 months ago)
- Topics: json2ts, tools, typescript
- Language: JavaScript
- Homepage:
- Size: 1.48 MB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# json2ts
Automatically generate typescript definition file from url

## Install``` bash
npm install json2ts-core --save-dev
```## Usage(CLI)
you can generate multiple ts definition files for api site,like [NEI](https://nei.netease.com/)(default). or generate single file for your single url address.```
json2ts -u=your-web-url
``````
--version Show version number [boolean]
-u, --url your web url [required]
-m, --method your web url method [default: "get"]
-t, --target typescript interface target folder path [default: "./interfaces"]
-p, --property export response property interface
-h, --help Show help [boolean]
```## Usage(API)
you can use api to parser user-defined rule.
``` js
const json2ts = require('json2ts-core/src/json2ts')json2ts({url: 'http://localhost:8002'}, ($) => {
// your rule to parser page
$('selector').each(function(index, element) {
...
arr.push({ url, method })
})
return arr
})
```## License
The code is distributed under the [MIT](http://opensource.org/licenses/MIT) license