{"id":16774757,"url":"https://github.com/iohannrabeson/cpp2json","last_synced_at":"2025-04-10T20:07:52.839Z","repository":{"id":48382899,"uuid":"103037083","full_name":"IohannRabeson/cpp2json","owner":"IohannRabeson","description":"Export meta-informations about your C++ using Clang","archived":false,"fork":false,"pushed_at":"2021-07-29T06:50:14.000Z","size":93,"stargazers_count":7,"open_issues_count":9,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-24T17:52:42.562Z","etag":null,"topics":["c-plus-plus","clang","code-generation","cpp14","json","llvm","reflection"],"latest_commit_sha":null,"homepage":"","language":"C++","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/IohannRabeson.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":"2017-09-10T14:45:36.000Z","updated_at":"2023-12-09T23:30:43.000Z","dependencies_parsed_at":"2022-08-26T00:12:53.675Z","dependency_job_id":null,"html_url":"https://github.com/IohannRabeson/cpp2json","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IohannRabeson%2Fcpp2json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IohannRabeson%2Fcpp2json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IohannRabeson%2Fcpp2json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IohannRabeson%2Fcpp2json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IohannRabeson","download_url":"https://codeload.github.com/IohannRabeson/cpp2json/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248288347,"owners_count":21078903,"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":["c-plus-plus","clang","code-generation","cpp14","json","llvm","reflection"],"created_at":"2024-10-13T06:50:01.520Z","updated_at":"2025-04-10T20:07:52.819Z","avatar_url":"https://github.com/IohannRabeson.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cpp2Json [![Build Status](https://travis-ci.com/IohannRabeson/cpp2json.svg?token=oSgYDG8ZHmxB1gxGNZxP\u0026branch=master)](https://travis-ci.com/IohannRabeson/cpp2json) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/456265ad762c40d5aca25cb649589c69)](https://www.codacy.com/app/IohannRabeson/cpp2json?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=IohannRabeson/cpp2json\u0026amp;utm_campaign=Badge_Grade)\n\n![general_usage](https://docs.google.com/drawings/d/e/2PACX-1vSvz2O3s9Oica9CyYAUq42n7U62ygswZS-CPsdTIPUDFLky-4Ff0zx-U-kBqJSubkmiBsJ9GsByTDsl/pub?w=1149\u0026h=542)\n\nA tool to extract C++ information about enumerations, classes, methods and attributes.  \nAll theses data are stored as JSON.\n\nInitial idea picked up from this conference by Sergiy Migdalskiy: https://archive.org/details/GDC2014Migdalskiy\n\n## Requirements\n\n- Llvm 11\n- RapidJson 1.x\n\nYou might need to give the path to the llvm folder to CMake:\n```bash\nmkdir builds \u0026\u0026 cd builds\ncmake .. -G Ninja -DCMAKE_PREFIX_PATH=\u003cyour_path_to_llvm_install\u003e\nninja\n```\nWith brew you can print the path using:\n```bash\nbrew --prefix llvm\n```\n```bash\ncmake .. -G Ninja -DCMAKE_PREFIX_PATH=\"$(brew --prefix llvm)\"\n```\n\n## Example\nFile test_example.hpp:\n```c++\n#ifndef CPP2JSON_TEST_EXAMPLE_HPP\n#define CPP2JSON_TEST_EXAMPLE_HPP\n#include \u003cstring\u003e\n\nstruct Example01\n{\n    float m_float;\n    std::string m_string;\n    int m_int;\n};\n\n#endif //CPP2JSON_TEST_EXAMPLE_HPP\n```\n\nRun cpp2json on it:\n```bash\n$\u003e cpp2json test_example.hpp --pretty --\n```\n\nWill give you the following JSON output:\n```json\n{\n    \"classes\": {\n        \"Example01\": {\n            \"fields\": [\n                {\n                    \"name\": \"m_float\",\n                    \"type\": {\n                        \"key\": \"float\",\n                        \"expression\": \"float\",\n                        \"pointer\": false,\n                        \"array\": false,\n                        \"reference\": false,\n                        \"const\": false,\n                        \"volatile\": false,\n                        \"literal\": true,\n                        \"enum\": false\n                    }\n                },\n                {\n                    \"name\": \"m_string\",\n                    \"type\": {\n                        \"key\": \"std::string\",\n                        \"expression\": \"std::string\",\n                        \"pointer\": false,\n                        \"array\": false,\n                        \"reference\": false,\n                        \"const\": false,\n                        \"volatile\": false,\n                        \"literal\": false,\n                        \"enum\": false\n                    }\n                },\n                {\n                    \"name\": \"m_int\",\n                    \"type\": {\n                        \"key\": \"int\",\n                        \"expression\": \"int\",\n                        \"pointer\": false,\n                        \"array\": false,\n                        \"reference\": false,\n                        \"const\": false,\n                        \"volatile\": false,\n                        \"literal\": true,\n                        \"enum\": false\n                    }\n                }\n            ],\n            \"methods\": [],\n            \"annotations\": [],\n            \"bases\": [],\n            \"file\": \"/Users/iota/projects/tools/cpp2json/sources/tests/resources/test_example.hpp\"\n        }\n    },\n    \"enums\": {}\n}\n```\n## Usage\n```bash\nUSAGE: cpp2json [options] \u003csource0\u003e [... \u003csourceN\u003e]\n\nOPTIONS:\n\nGeneric Options:\n\n  -help                                    - Display available options (-help-hidden for more)\n  -help-list                               - Display list of available options (-help-list-hidden for more)\n  -version                                 - Display the version of this program\n\nMain options:\n\n  -append                                  - Append output\n  -exclude_annotation=\u003cannotation content\u003e - Specify the content for exclude annotation\n  -extra-arg=\u003cstring\u003e                      - Additional argument to append to the compiler command line\n  -extra-arg-before=\u003cstring\u003e               - Additional argument to prepend to the compiler command line\n  -output=\u003cfilename\u003e                       - Specify output JSON filename.\n                                             You can also send the output to the stdout using - instead of a filename\n  -p=\u003cstring\u003e                              - Build path\n  -pretty                                  - Output pretty JSON\n```\nNote the -- is really needed because to define where the options passed to the clang driver begins.  \nIf cpp2json can't find standard includes (it can happen if you have moved cpp2json in another location), you should specify\nyourself using the correct llvm include paths using `-I` (after the --).\n\nDon't forget to specify the c++ version used as clang option (e.g: -std=c++14).\nExample:\n```\n  cpp2json [options] \u003csource0\u003e [... \u003csourceN\u003e] -- -std=c++14\n```\nThis is required because clang assume the executable is located in a standard directory (in llvm/bin) and use that\nto deduce the includes paths.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiohannrabeson%2Fcpp2json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiohannrabeson%2Fcpp2json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiohannrabeson%2Fcpp2json/lists"}