Education purpose C++17 JSON parser, teach you how to parsing string and numeric literials, as well as using std::variant and std::optional elegently.
Bilibili Video: https://www.bilibili.com/video/BV1pa4y1g7v6
cmake -B build
cmake --build build
build/main
- Implement the parsing of three special literials: null, false, true and test them in recursive cases.
- Support string literials in single-quotes as well, e.g. 'string' and "string" should both work.
- Support for hex character escape sequence like '\x0D' in string (may need two more phase enums: Hex1, Hex2).
- Support for UCS2 character escape sequence like '\u000D' in string, and encode it as UTF-8 into std::string.
- Support for UCS4 character escape sequence like '\U0000000D' in string, and encode it as UTF-8 into std::string.
- Support any JSONObject to be key for JSONDict (requires hash and equal_to traits for JSONObject).
- Implement a JSON dumper (as an opposite to the parser) as well.
- Add an optional argument 'isPretty' in the dump() function, when true, dump JSON with indent and spaces.
- Support JSONDict keys to be optionally not quoted, e.g. {"hello": "world"} and {hello: "world"} are equivalent.
- Extend this JSON parser / dumper into a YAML parser / dumper (YAML is a superset of JSON).