{"id":44968702,"url":"https://github.com/cfhamlet/os-jsonbind","last_synced_at":"2026-02-18T15:03:59.115Z","repository":{"id":46087660,"uuid":"424257389","full_name":"cfhamlet/os-jsonbind","owner":"cfhamlet","description":"Bind data with JSON schema","archived":false,"fork":false,"pushed_at":"2021-11-15T13:18:08.000Z","size":18,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-06-20T00:33:54.163Z","etag":null,"topics":["extractor","json","jsonschema"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cfhamlet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-03T14:30:12.000Z","updated_at":"2022-01-10T12:47:23.000Z","dependencies_parsed_at":"2022-09-11T21:34:56.038Z","dependency_job_id":null,"html_url":"https://github.com/cfhamlet/os-jsonbind","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/cfhamlet/os-jsonbind","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cfhamlet%2Fos-jsonbind","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cfhamlet%2Fos-jsonbind/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cfhamlet%2Fos-jsonbind/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cfhamlet%2Fos-jsonbind/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cfhamlet","download_url":"https://codeload.github.com/cfhamlet/os-jsonbind/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cfhamlet%2Fos-jsonbind/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29582860,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T13:56:48.962Z","status":"ssl_error","status_checked_at":"2026-02-18T13:54:34.145Z","response_time":162,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["extractor","json","jsonschema"],"created_at":"2026-02-18T15:03:59.038Z","updated_at":"2026-02-18T15:03:59.106Z","avatar_url":"https://github.com/cfhamlet.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# os-jsonbind\nExtract data with JSON schema\n\nThis library extend json schema, you can predefine standard json schema with extend tags, which can be used for extract data from source data(bytes) and create new data for json\n\n## Install\n\n```\ngo get github.com/cfhamlet/os-jsonbind\n```\n\n## Usage\n\n* source data\n\n    ```\n    srcData := []byte(`{\"k1\": 1, \"k2\": \"v2\", \"k3\": [2,3,4], \"k4\": {\"i1\": 5, \"i2\": true}}`) // json bytes\n    ```\n\n* define a json schema of the target object with \"bind\" key, value is path string of the source data\n\n\n    ```\n    spec := []byte(`{\"properties\": {\"K\": {\"type\": \"number\", \"bind\": \"k1\"}}}`) // \"k1\" gjson style\n    ```\n\n* create a binder with the schema\n\n    ```\n    import \"github.com/cfhamlet/os-jsonbind\"\n    \n    binder, err := jsonbind.Compile(spec)\n    ```\n* extract data from source data, return target result, binded flag and error\n\n    ```\n    result, binded, err := binder.Bind(context.Background(), srcData)\n    // result is map[string]interface{}{\"K\": 1}\n    // binded is true\n    // err is null\n    ```\n\n### Rule Syntax\n\nThe default rule type is [gjson](https://github.com/tidwall/gjson), you can specify other syntax with rule name as prefix\n\n```\n\"bind\": \"ajson:$.k1\"\n```\n\nSupported syntax rule types:\n* ojg: https://github.com/oliveagle/jsonpath\n* gval: https://github.com/PaesslerAG/gval\n* gjson: https://github.com/tidwall/gjson\n* ojson: https://github.com/oliveagle/jsonpath\n* ajson: https://github.com/spyzhov/ajson\n\n\n\n## License\n\nMIT licensed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcfhamlet%2Fos-jsonbind","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcfhamlet%2Fos-jsonbind","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcfhamlet%2Fos-jsonbind/lists"}