{"id":13805640,"url":"https://github.com/lydiandy/cjson","last_synced_at":"2026-03-13T19:47:23.065Z","repository":{"id":184214206,"uuid":"245065689","full_name":"lydiandy/cjson","owner":"lydiandy","description":"wrap cJSON for vlang","archived":false,"fork":false,"pushed_at":"2022-07-08T16:44:56.000Z","size":85,"stargazers_count":12,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-06T14:07:43.374Z","etag":null,"topics":["cjson","v","vlang"],"latest_commit_sha":null,"homepage":null,"language":"V","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/lydiandy.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,"governance":null}},"created_at":"2020-03-05T04:08:11.000Z","updated_at":"2025-02-18T10:30:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"2b02a011-c55c-4957-a0e8-b4c005b595d5","html_url":"https://github.com/lydiandy/cjson","commit_stats":null,"previous_names":["lydiandy/cjson"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lydiandy%2Fcjson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lydiandy%2Fcjson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lydiandy%2Fcjson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lydiandy%2Fcjson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lydiandy","download_url":"https://codeload.github.com/lydiandy/cjson/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254012987,"owners_count":21999346,"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","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":["cjson","v","vlang"],"created_at":"2024-08-04T01:01:03.355Z","updated_at":"2026-03-13T19:47:23.032Z","avatar_url":"https://github.com/lydiandy.png","language":"V","funding_links":[],"categories":["Libraries"],"sub_categories":["Text processing"],"readme":"## cjson\n\nwrap cJSON for vlang.\n\nV already has the standard json module base on cJSON,but only public json.encode() and json.decode(). \n\nsometimes we may need to use [cJSON](https://github.com/DaveGamble/cJSON) directly.\n\n## Installation\n\n- via vpm\n\n  ```\n  v install lydiandy.cjson\n  ```\n\n- via source\n\n  ```\n  git clone git@github.com:lydiandy/cjson.git\n  ln -s your/path ~/.vmodules/cjson\n  ```\n\n## usage\n\n```v\nmodule main\n\nimport cjson  // import lydiandy.cjson\n\n\nstruct User {\n\tname string\n\tage  int\n}\n\n\nfn main() {\n\t// cjson print\n\tu := User{name:'tom', age:18}\n\troot := cjson.create_object()\n\tcjson.add_item_to_object(root, \"name\", cjson.create_string(u.name))\n\tcjson.add_item_to_object(root, \"age\", cjson.create_number(u.age))\n\tjson_str := cjson.json_print(root)\n\tprintln(json_str)\n\n\t// cjson parse\n\tjson_content:='{\"name\":\"jack\",\"age\":22}'\n\tres := cjson.json_parse(json_content)\n\t\n\tname := cjson.get_object_item(res, 'name')\n\tage := cjson.get_object_item(res, 'age')\n\tprintln(name.valuestring)\n\tprintln(age.valueint)\n\n\t// simple way to use cjson\n\tsimple_example()\n}\n\n\nfn simple_example() {\n\tprintln('======== simple print json =========')\n\tuser := cjson.obj()\n\tuser.set(\"name\", cjson.str(\"Tom\"))\n\tuser.set(\"age\", cjson.num(18))\n\tuser.set(\"score\", cjson.num(6.2))\n\tuser.set(\"gender\", cjson.boolean(true))\n\tuser.set(\"password\", cjson.null())\n\n\tfriend := cjson.obj()\n\tfriend.set(\"name\", cjson.str(\"Jack\"))\n\tfriends := cjson.list()\n\tfriends.add(friend)\n\tuser.set(\"friends\", friends)\n\n\tleader := cjson.obj()\n\tleader.set(\"name\", cjson.str(\"Mike\"))\n\tuser.set(\"leader\", leader)\n\n\tjson_str := user.dump()\n\tprintln(json_str)\n\n\tprintln('======== simple parse json =========')\n\tjson_content := '{\n        \"name\": \"Tom\",\n        \"age\": 18,\n        \"score\": 6.2,\n        \"gender\": true,\n        \"password\": null,\n        \"friends\": [{\n\t\t\t\"name\": \"Jack\"\n\t\t}],\n        \"leader\": {\n\t\t\t\"name\": \"Mike\"\n        }\n\t}'\n\tobj := cjson.load(json_content)\n\tprintln(obj.get_str(\"name\"))\n\tprintln(obj.get_int(\"age\"))\n\tprintln(obj.get_num(\"score\"))\n\tprintln(obj.get_boolean(\"gender\"))\n\tprintln(obj.is_null(\"password\"))\n\tprintln(obj.get(\"leader\").get_str(\"name\"))\n}\n```\n\n## License\n\nMIT\n\n## Contributors\n\npull request is welcome ~","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flydiandy%2Fcjson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flydiandy%2Fcjson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flydiandy%2Fcjson/lists"}