Kick off your book project in 2 hours, get started with GhostAI in 2 hours, or do both! Free live workshops, on Zoom. You’ll leave with a real book project and a clear plan to keep going. Saturday, June 27, 2026.

Leanpub Header

Skip to main content

Building a Typed JSON Configuration Library in Modern C++

From JSON Parsing to Compile-Time Reflection: Build a Production-Ready Header-Only Configuration Library with C++23

The instructor has published 25% of this course.Last updated on 2026-06-18

Ever wondered how configuration libraries work under the hood?

Most C++ courses teach you how to use libraries. But in this course, you'll build one—from scratch.

You'll discover:

  • Why header-only libraries are the gold standard for C++ distribution
  • How compile-time reflection with CRTP eliminates repetitive mapping code
  • Why dot-notation makes nested JSON access elegant and intuitive
  • How to provide crystal-clear error messages that save hours of debugging
  • And how to build a production-ready library that you can actually use in your projects

No black boxes. No magic. Just C++23 at its best.

By the end, you won't just know how to use a configuration library—you'll know exactly how it works, why it's designed that way, and how you can build your own.

Ready to build your own typed JSON configuration library in modern C++?

Minimum price

$19.00

$29.00

You pay

Author earns

$

Also available for 1 course credit with a Learner Membership

PDF
EPUB
WEB
About

About

About the Course

Building a Typed JSON Configuration Library in Modern C++

In this hands-on course, you'll build a production-ready configuration library from scratch—not just to use it, but to understand every line of code, every design decision, and every C++23 feature that makes it possible.

What You'll Learn

By the end of this course, you'll be able to:

  • Design and implement header-only C++ libraries with clean, intuitive APIs
  • Use compile-time reflection with CRTP to automatically map JSON to C++ types
  • Implement template metaprogramming patterns like std::apply, fold expressions, and concepts
  • Build production-quality C++ code with comprehensive error handling and testing
  • Master C++23 features including string_view, concepts, ranges, and structured bindings

Course Structure

This course is organized into 4 modules over approximately 150 minutes:

  • Module 1 (30 min): Project setup and C++23 foundations—CMake, FetchContent, header-only library structure, C++23 essentials
  • Module 2 (40 min): Core configuration class—three-query API pattern (get, try_get, has), JSON parsing with nlohmann/json, error handling
  • Module 3 (35 min): Dot-notation and error handling—path traversal algorithm, nested key access, meaningful error messages with field context
  • Module 4 (45 min): Compile-time reflection and capstone—CRTP pattern, Field descriptors, HasFields concept, from_json/to_json, nested reflectables, and building a sample application

Who Is This For?

This course is designed for intermediate C++ developers who:

  • Have 1-2 years of C++ experience
  • Want to understand how libraries are built from the inside out
  • Are interested in modern C++23 features and template metaprogramming
  • Want to improve their library design and error handling skills

Prerequisites

  • Basic C++ knowledge (classes, templates, STL)
  • Interest in library design and C++ metaprogramming
  • C++23 compiler (Apple Clang 15+, GCC 13+, or MSVC 2022)
  • CMake 3.27+ (we'll show you how to install it)

What You'll Get

By the end of this course, you'll have:

  • A fully functional header-only configuration library that you built yourself
  • Deep understanding of C++23 features and when to use them
  • Practical experience with template metaprogramming and compile-time reflection
  • Production-ready code that you can use in your own projects
  • The confidence to design and implement your own C++ libraries

How We'll Learn

  • Build the library step by step
  • 5-10 minute lessons: Bite-sized, focused content
  • Code walkthroughs: Every line explained with clear reasoning
  • Quizzes: 3-5 questions per module to reinforce learning
  • Capstone project: Build a sample application using your library

Share this course

Instructor

About the Instructor

Eduard Ghergu, Ph.D.

For over 27 years, I’ve helped teams transform their codebases from legacy liabilities to scalable, maintainable systems through clean architecture, domain-driven design, and hands-on mentorship. My books and courses distill decades of real-world experience into actionable insights—no fluff, just proven patterns.

Material

Course Material

  • C++23 Configuration Library: Build Your Own Header-Only JSON Parser

  • Course Introduction

  • Why Build Your Own?

  • What You’ll Learn

  • Course Structure

  • Who Is This For?

  • Prerequisites

  • How to Use This Course

  • What You’ll Get

  • Module 1 - Project Setup & C++23 Foundations

  • Lessons

  • Duration

  • Learning Objectives

  • Quiz

  • Module 1 - Lesson 1

  • Why C++23?

  • Installation Steps

  • Step 1: Install CLion IDE

  • Step 2: Verify Your Setup

  • Common Pitfalls

  • Summary Checklist

  • Transition

  • Module 1 - Lesson 2

  • Project Structure for Header-Only Libraries

  • Why This Structure?

  • Setting Up the Project

  • Step 1: Create the Directory Structure

  • Step 2: Create the Main Header File

  • Step 3: Create the Root CMakeLists.txt

  • Step 4: Create the Tests CMakeLists.txt

  • Step 5: Create a Sample Test

  • Step 6: Create an Example

  • Verifying the Setup

  • Common Pitfalls

  • Summary Checklist

  • Transition

  • Module 1 - Lesson 3

  • Why Header-Only?

  • Our Project Structure

  • The `include/` Directory

  • The `tests/` Directory

  • The `CMakeLists.txt` File

  • The `compile_commands.json` File

  • Header-Only Design Patterns

  • 1. Single Header Per Component

  • 2. Traditional Include Guards (Preferred)

  • 3. Header-Only Template Classes

  • What We Won’t Have

  • Real-World Examples

  • Summary Checklist

  • Transition

  • Module 1 - Lesson 4

  • Why C++23?

  • 1. std::string_view — Efficient String Handling

  • 2. C++20 Concepts — Type Constraints

  • 3. Range-based for — Modern Iteration

  • Lambda Expressions — Quick Primer

  • 4. Structured Bindings — Destructuring

  • 5. if with Initializer — Scope Control

  • Summary Checklist

  • Transition

  • Module 1 - Lesson 5

  • What is CMake?

  • Our Minimal CMakeLists.txt

  • 1. Project Declaration

  • 2. C++ Standard Settings

  • 3. Interface Library

  • 4. Include Directories

  • Building the Project

  • Using the Library

  • Common Pitfalls

  • Summary Checklist

  • References

  • Transition

  • Module 1 - Lesson 6

  • What is FetchContent?

  • Fetching nlohmann/json

  • Fetching GoogleTest

  • Linking Dependencies

  • Complete FetchContent Setup

  • Why Git Tags?

  • Common Pitfalls

  • Building with Dependencies

  • Summary Checklist

  • References

  • Transition

  • Module 1 - Quiz

  • Quiz

    3 attempts allowed

  • Scoring

  • Module 2: Core Configuration Class

  • Lessons

  • Duration

  • Learning Objectives

  • Quiz

  • Module 3: Dot-Notation and Error Handling

  • Lessons

  • Duration

  • Learning Objectives

  • Quiz

  • Module 4 - Compile-Time Reflection

  • Lessons

  • Duration

  • Learning Objectives

  • Capstone Project

  • Quiz

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub