Coder Social home page Coder Social logo

leauny / babyjson-demo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from archibate/babyjson-demo

0.0 0.0 0.0 5 KB

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.

C++ 98.85% CMake 1.15%

babyjson-demo's Introduction

babyjson-demo

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

How to Run

cmake -B build
cmake --build build
build/main

Homework

  1. Implement the parsing of three special literials: null, false, true and test them in recursive cases.
  2. Support string literials in single-quotes as well, e.g. 'string' and "string" should both work.
  3. Support for hex character escape sequence like '\x0D' in string (may need two more phase enums: Hex1, Hex2).

Challenge (accept if you can)

  1. Support for UCS2 character escape sequence like '\u000D' in string, and encode it as UTF-8 into std::string.
  2. Support for UCS4 character escape sequence like '\U0000000D' in string, and encode it as UTF-8 into std::string.
  3. Support any JSONObject to be key for JSONDict (requires hash and equal_to traits for JSONObject).
  4. Implement a JSON dumper (as an opposite to the parser) as well.
  5. Add an optional argument 'isPretty' in the dump() function, when true, dump JSON with indent and spaces.
  6. Support JSONDict keys to be optionally not quoted, e.g. {"hello": "world"} and {hello: "world"} are equivalent.
  7. Extend this JSON parser / dumper into a YAML parser / dumper (YAML is a superset of JSON).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.