{"id":20252604,"url":"https://github.com/streamdal/thrifty","last_synced_at":"2025-09-02T04:07:04.338Z","repository":{"id":61626576,"uuid":"537667172","full_name":"streamdal/thrifty","owner":"streamdal","description":"Library for decoding thrift wire format from binary to JSON using IDL definition","archived":false,"fork":false,"pushed_at":"2022-09-19T19:32:09.000Z","size":43,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-06-18T19:48:09.296Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/streamdal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-09-17T01:30:26.000Z","updated_at":"2022-09-20T20:38:08.000Z","dependencies_parsed_at":"2022-10-19T19:00:26.322Z","dependency_job_id":null,"html_url":"https://github.com/streamdal/thrifty","commit_stats":null,"previous_names":["batchcorp/thrifty"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/streamdal/thrifty","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamdal%2Fthrifty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamdal%2Fthrifty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamdal%2Fthrifty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamdal%2Fthrifty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/streamdal","download_url":"https://codeload.github.com/streamdal/thrifty/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamdal%2Fthrifty/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273227973,"owners_count":25067693,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-02T02:00:09.530Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T10:17:33.011Z","updated_at":"2025-09-02T04:07:04.317Z","avatar_url":"https://github.com/streamdal.png","language":"Go","readme":"# Thrifty\n---\nThrifty is used to transform a wire-format thrift message into a JSON representation\nusing an IDL definition. This library builds upon github.com/thrift-iterator/go by utilizing\nthe IDL definition in order to properly represent field names and enum values in the output\ninstead of IDs.\n\n\n## Usage\n\nFirst parse the IDL:\n\n```go\nidlFiles := map[string][]byte{\n\t\"simple.thrift\": []byte(`\n            namespace go sh.batch.schema\n            \n            struct Account {\n              1: i32 id\n              2: string first_name\n              3: string last_name\n              4: string email\n            }\n        `),\n}\n\n\nidl, err := thrifty.ParseIDLFiles(idlFiles)\nif err != nil {\n\tlog.Fatalf(\"unable to parse IDL files: %s\", err.Error())\n}\n```\n\nThen decode the binary message data using the parsed IDL. The struct name must be prefixed with the full namespace\n `\"sh.batch.schema.Account\"` as shown: \n\n```go\ndecodedMsg, err := thrify.DecodeWithParsedIDL(idl, msgData, \"sh.batch.schema.Account\")\nif err != nil {\n\tlog.Fatalf(\"unable to decode thrift message: %s\", err.Error())\n}\n```\n\nThe result of decodedMsg will be JSON in `[]byte` format:\n\n```go\nprintln(string(decodedMsg))\n```\n\nOutput:\n```json\n{\"first_name\": \"Gopher\", \"last_name\": \"Golang\", \"email\": \"gopher@golang.org\", \"id\": 348590795}\n```\n\n\n## Benchmarks\n\nSingle struct: \n```\nstruct Account {\n  1: i32 id\n  2: string first_name\n  3: string last_name\n  4: string email\n}\n```\n\n```bash\ngoos: darwin\ngoarch: arm64\npkg: github.com/batchcorp/thrifty\nBenchmarkParseIDL-8              \t  192861\t      6335 ns/op\nBenchmarkDecodeWithParsedIDL-8   \t  974961\t      1129 ns/op\nBenchmarkDecodeWithRawIDL-8      \t  154863\t      7734 ns/op\n```\n\nMultiple nested structs:\n```\nstruct Account {\n  1: i32 id\n  2: string first_name\n  3: string last_name\n  4: string email\n  5: Billing billing\n  6: Address address\n  7: Deep1 deep_nested\n}\n\nstruct Billing {\n  1: string card_number\n  2: i32 exp_month\n  3: i32 exp_year\n}\n\nstruct Address {\n  1: string street\n  2: string city\n  3: string state_province\n  4: string country\n  5: string postal_code\n}\n\nstruct Deep1 {\n  1: Deep2 deep2\n}\n\nstruct Deep2 {\n  1: Deep3 deep3\n}\n\nstruct Deep3 {\n  1: string nested_value\n}\n```\n\n```bash\ngoos: darwin\ngoarch: arm64\npkg: github.com/batchcorp/thrifty\nBenchmarkParseIDL_nested-8              \t   51273\t     23310 ns/op\nBenchmarkDecodeWithParsedIDL_nested-8   \t  261242\t      4602 ns/op\nBenchmarkDecodeWithRawIDL_nested-8      \t   39578\t     28945 ns/op\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstreamdal%2Fthrifty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstreamdal%2Fthrifty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstreamdal%2Fthrifty/lists"}