UNPKG

head2json

Version:

Parses C++ files and converts the header to a JSON object.

42 lines (37 loc) 646 B
# C++ Header Parser ![npm](https://img.shields.io/npm/v/head2json?style=for-the-badge) ## Installation With [npm](https://www.npmjs.com/) installed, do ``` $ npm install head2json ``` ## Example So you have a file `example.cpp`: ```cpp /* INT: 1 STRING: String List: - ListItem1 - ListItem2 */ #include <bits/stdc++.h> using namespace std; int main() { cout <<"Hello World\n"; return 0; } ``` In your NodeJS file, ```js const parseHeader = require('head2json'); console.log(parseHeader('./example.cpp')) ``` The result is ```json { "INT": 1, "STRING": "String", "List": [ "ListItem1", "ListItem2" ] } ```