1.0.5 • Published 6 years ago

thrift-json v1.0.5

Weekly downloads
9
License
MIT
Repository
github
Last release
6 years ago

thrift-json

parse thift idl info to json based on thriftpy

Installation

npm i thrift-json

Usage

var thriftToJSON = require('thrift-json');
thriftToJSON('/foo/bar.thrift').then(results => console.log(results));
// 或
thriftToJSON(['/foo/bar1.thrift', '/foo/bar2.thrift']).then(results => console.log(results));

Output

Example:

[
    {
        "source": "/foo/bar.thrift",
        "value": {
            "structs": {
                "CityInfo": "{id?:number,name?:string,pinyin?:string,acronym?:string,rank?:string,firstChar?:string}",
                "RecommendRequest": "{userId:number,cityId:number,lat:number,lng:number,uuid:string,poiId?:number}",
                "RecommendInfo": "{itemId?:number,title?:string,imgUrl?:string,score?:string,consumeNum?:number,areaName?:string,lowPrice?:string,saleNum?:number,commentNum?:number,detailUrl?:string,firstCate:Array<number>,avgPrice?:number}",
                "PcHomeCategory": "{id?:number,name?:string,url?:string,pinyin?:string}",
                "HomeCategoryResponse": "{leftPcHomeCategoryList:Array<PcHomeCategory>,rightPcHomeCategoryList:Array<Array<PcHomeCategory>>}",
                "GeneralCategory": "{pcHomeCategory:PcHomeCategory,subPcHomeCategory:Array<PcHomeCategory>}",
                "PoiListCategory": "{pcHomeCategory:PcHomeCategory,generalCategoryList:Array<GeneralCategory>}"
            },
            "services": {
                "WebApiService": {
                    "getNearCity": {
                        "args": "cityId:number",
                        "result": "Array<CityInfo>",
                        "empty": []
                    },
                    "getRecommendInfo": {
                        "args": "req:RecommendRequest",
                        "result": "Array<RecommendInfo>",
                        "empty": []
                    },
                    "getCategory": {
                        "args": "cityId:number",
                        "result": "Array<HomeCategoryResponse>",
                        "empty": []
                    }
                }
            },
            "includes": [
                "common"
            ]
        }
    }
]

the results include:

  1. Typescript definition for structs and methods.
  2. Empty output for methods.
  3. Name of thrift files included.
1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago