{"id":13806186,"url":"https://github.com/nedpals/v-jsonrpc","last_synced_at":"2026-01-21T11:02:41.657Z","repository":{"id":47623973,"uuid":"219173763","full_name":"nedpals/v-jsonrpc","owner":"nedpals","description":"Basic JSON-RPC 2.0-compliant server written on V.","archived":false,"fork":false,"pushed_at":"2021-08-21T04:20:28.000Z","size":89,"stargazers_count":34,"open_issues_count":1,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-08T21:48:34.424Z","etag":null,"topics":["json-rpc-server","json-rpc2","v","vlang"],"latest_commit_sha":null,"homepage":"","language":"V","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/nedpals.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":"2019-11-02T15:31:34.000Z","updated_at":"2025-03-29T23:23:46.000Z","dependencies_parsed_at":"2022-08-29T23:22:05.976Z","dependency_job_id":null,"html_url":"https://github.com/nedpals/v-jsonrpc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nedpals/v-jsonrpc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nedpals%2Fv-jsonrpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nedpals%2Fv-jsonrpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nedpals%2Fv-jsonrpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nedpals%2Fv-jsonrpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nedpals","download_url":"https://codeload.github.com/nedpals/v-jsonrpc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nedpals%2Fv-jsonrpc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28632258,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T04:47:28.174Z","status":"ssl_error","status_checked_at":"2026-01-21T04:47:22.943Z","response_time":86,"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":["json-rpc-server","json-rpc2","v","vlang"],"created_at":"2024-08-04T01:01:08.660Z","updated_at":"2026-01-21T11:02:41.640Z","avatar_url":"https://github.com/nedpals.png","language":"V","funding_links":[],"categories":["Libraries"],"sub_categories":["Web"],"readme":"# V-JSONRPC\nA basic JSON-RPC 2.0-compliant server written on V. V-JSONRPC 0.2 is now transfer protocol-independent meaning it is not tied to one protocol and it can now be used in other ways such as STDIN, TCP, UDP and more provided that the provided input is a string.\n\n## Install\n### VPM\n```\nv install nedpals.jsonrpc\n```\n\n### [vpkg](https://github.com/vpkg-project/vpkg)\n```\nvpkg get v-jsonrpc\n```\n\n## Example\nThis code example is taken from the [`stdin_example.v`](examples/stdin_example.v) which uses a standard input (STDIN) as the main source for calling procedures.\n\n```v\nfn emit_error(err_code int) Response {\n    mut eres := Response{}\n    eres.send_error(err_code)\n    return eres\n}\n\nfn greet_person(ctx mut Context) string {\n    name := jsonrpc.as_string(ctx.req.params)\n    return 'Hello, $name'\n}\n\nfn main() {\n    srv := jsonrpc.new()\n    srv.register('greet', greet_person)\n\n    for {\n        line := os.get_line()\n        res := srv.exec(line) or { \n            err_code := err.int()\n            eres := emit_error(err_code)\n            println(eres.gen_json())\n            continue\n        }\n\n        println(res.gen_json())\n    }\n}\n```\n\n### Error Handling\nV-JSONRPC includes basic error handling as well as a set of public constants for easy use.\n```golang\npub const (\n    PARSE_ERROR = -32700\n    INVALID_REQUEST = -32600\n    METHOD_NOT_FOUND = -32601\n    INVALID_PARAMS = -32602\n    INTERNAL_ERROR = -32693    \n    SERVER_ERROR_START = -32099\n    SERVER_ERROR_END = -32600\n    SERVER_NOT_INITIALIZED = -32002\n    UNKNOWN_ERROR_CODE = -32001\n)\n```\n\n```v\n//... Function context must be mutable. e.g fn proc_name(ctx mut jsonrpc.Context)\n    ctx.res.send_error(jsonrpc.INVALID_REQUEST)\n    return 'error!'\n//...\n```\n\n```json\n{\n    \"jsonrpc\":\"2.0\",\n    \"id\":0,\n    \"error\":{\n        \"code\":-32600,\n        \"message\":\"Invalid request.\",\n        \"data\":\"\"\n    }\n}\n```\n\n## Parameter/Payload Handling\nDue to the limitations of the language, the payload (aka the `param` key) is decoded as a raw string. This means that the parsing of data into its appropriate type must be done inside the procedure handler. For strings and primitive arrays (like `[]string`), V-JSONRPC provides functions for it (`as_array` for array and `as_string` for string).\n\n```v\nfn get_person(ctx mut Context) string {\n    // The params is manually decoded into the Person struct\n    person := json.decode(Person, ctx.req.params) or {}\n    return person.str()\n}\n```\n\n## Migration from `0.1`\nV-JSONRPC 0.2 is different from the previous version when it comes to the function names and the way it is used. If you are using the previous version of V-JSONRPC and want to migrate to the new version, you should do the following:\n\n- The built-in TCP server has been removed. Use the code from the [`tcp_example.v`](examples/tcp_example.v) to use V-JSONRPC via TCP.\n- `register_procedure` is now `register`.\n\n## Special thanks\nSpecial huge thanks to [spytheman](https://github.com/spytheman/) for reviewing and fixing the code!\n\n## Contributing\n1. Fork it (\u003chttps://github.com/nedpals/v-jsonrpc/fork\u003e)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## License\n[MIT](LICENSE)\n\n## Contributors\n\n- [Ned Palacios](https://github.com/nedpals) - creator and maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnedpals%2Fv-jsonrpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnedpals%2Fv-jsonrpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnedpals%2Fv-jsonrpc/lists"}