{"id":45174098,"url":"https://github.com/sfxfs/mjsonrpc","last_synced_at":"2026-02-20T09:06:36.720Z","repository":{"id":259388001,"uuid":"868964069","full_name":"sfxfs/mjsonrpc","owner":"sfxfs","description":"A JSON-RPC 2.0 Message Parser and Generator Based in ANSI C | 基于 C 语言的 JSON-RPC 2.0 的消息解析器和生成器","archived":false,"fork":false,"pushed_at":"2026-02-17T10:27:48.000Z","size":328,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-17T14:34:03.953Z","etag":null,"topics":["c","json","jsonrpc2","rpc"],"latest_commit_sha":null,"homepage":"https://sfxfs.github.io/mjsonrpc/","language":"C","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/sfxfs.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-10-07T13:41:42.000Z","updated_at":"2026-02-17T10:27:28.000Z","dependencies_parsed_at":"2024-12-13T07:22:35.165Z","dependency_job_id":"d4a1ee3c-07cd-4353-969a-70d1d0811cc5","html_url":"https://github.com/sfxfs/mjsonrpc","commit_stats":null,"previous_names":["sfxfs/mjsonrpc"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/sfxfs/mjsonrpc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfxfs%2Fmjsonrpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfxfs%2Fmjsonrpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfxfs%2Fmjsonrpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfxfs%2Fmjsonrpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sfxfs","download_url":"https://codeload.github.com/sfxfs/mjsonrpc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfxfs%2Fmjsonrpc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29646576,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-20T08:48:14.886Z","status":"ssl_error","status_checked_at":"2026-02-20T08:45:26.777Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["c","json","jsonrpc2","rpc"],"created_at":"2026-02-20T09:06:36.242Z","updated_at":"2026-02-20T09:06:36.712Z","avatar_url":"https://github.com/sfxfs.png","language":"C","readme":"# mjsonrpc - A JSON-RPC 2.0 Message Parser and Generator Based on cJSON\n\n![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/sfxfs/mjsonrpc/ci.yml) ![GitHub License](https://img.shields.io/github/license/sfxfs/mjsonrpc) ![GitHub commit activity](https://img.shields.io/github/commit-activity/t/sfxfs/mjsonrpc) ![GitHub top language](https://img.shields.io/github/languages/top/sfxfs/mjsonrpc) ![GitHub repo size](https://img.shields.io/github/repo-size/sfxfs/mjsonrpc) ![GitHub Downloads (all assets, latest release)](https://img.shields.io/github/downloads/sfxfs/mjsonrpc/latest/total)\n\n[ English | [中文](README_CN.md) ]\n\n### Introduction\n\nThis project is lightweight, has minimal dependencies, and can be integrated into various communication methods (TCP, UDP, message queues, etc.). It is simple to use (with only a few functional APIs) and has good performance (using hash-based indexing instead of polling all methods). It also supports batch calls (JSON Array), automatic generation of corresponding error messages or custom error messages based on requests, customizable memory management hooks, notification requests, and more.\n\n### Features\n\n- **Lightweight \u0026 Minimal Dependencies**: Only depends on cJSON\n- **Hash-based Method Indexing**: Fast method lookup\n- **Batch Requests**: Support for JSON Array batch calls\n- **Customizable Memory Management**: User-defined malloc/free/strdup hooks\n- **Thread-Safe**: Thread-local storage for memory hooks\n- **POSIX Array Params**: Support for both object and array parameters\n- **Method Enumeration**: Query registered methods at runtime\n\n### How to Use\n\nSimply add the project source files (**mjsonrpc.c**, **mjsonrpc.h**) and the cJSON library to your own project and compile them together. Alternatively, you can compile them into a dynamic library and link it.\n\n### Function Definitions\n\nFor detailed API descriptions, please refer to **src/mjsonrpc.h** and [Doxygen docs of this repo](https://sfxfs.github.io/mjsonrpc).\n\n### Example\n\n```c\n#include \"mjsonrpc.h\"\n#include \u003cstdio.h\u003e\n#include \u003cstdlib.h\u003e\n\n// Define a simple JSON-RPC method\ncJSON *hello_world(mjrpc_func_ctx_t *context, cJSON *params, cJSON *id) {\n    cJSON *result = cJSON_CreateString(\"Hello, World!\");\n    return result;\n}\n\nint main() {\n    // Initialize mjrpc_handle_t\n    mjrpc_handle_t* handle = mjrpc_create_handle(0);\n\n    // Add a method\n    mjrpc_add_method(handle, hello_world, \"hello\", NULL);\n\n    // Construct a JSON-RPC request\n    const char *json_request = \"{\\\"jsonrpc\\\":\\\"2.0\\\",\\\"method\\\":\\\"hello\\\",\\\"id\\\":1}\";\n\n    // Process the request\n    int result;\n    char *json_response = mjrpc_process_str(handle, json_request, \u0026result);\n\n    // Check return code\n    if (result != MJRPC_RET_OK) {\n        printf(\"Error processing request: %d\\n\", result);\n    }\n\n    // Check response string\n    if (json_response) {\n        printf(\"Response: %s\\n\", json_response);\n        free(json_response);\n    }\n\n    // Cleanup\n    mjrpc_destroy_handle(handle);\n\n    return 0;\n}\n```\n\n### References\n\n- [DaveGamble/cJSON](https://github.com/DaveGamble/cJSON)\n- [JSON-RPC Specification](https://www.jsonrpc.org/specification)\n- [hmng/jsonrpc-c](https://github.com/hmng/jsonrpc-c)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsfxfs%2Fmjsonrpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsfxfs%2Fmjsonrpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsfxfs%2Fmjsonrpc/lists"}