Using JSON in Modern C++

A practical guide to working with the JSON data format in C++ using the popular nlohmann::json library.

Ryan McCombe
Updated
Hello! I'm here to help you with any questions about this lesson. Feel free to ask me anything - whether it's about specific concepts, examples, or how to apply what you've learned!

Questions & Answers

Answers are generated by AI models and may not have been reviewed. Be mindful when running any code on your device.

Creating a JSON object from a file
How can I create a JSON object by reading the contents of a JSON file?
Checking if a key exists in JSON
What is the best way to check if a specific key exists in a JSON object?
Pretty-printing JSON
How can I print out JSON in a nicely formatted way?
Serializing private class members to JSON
How can I serialize private members of a class to JSON?
Using custom types as JSON keys
Can I use a custom type as a key in a JSON object?
Adding comments to JSON
Can I add comments to a JSON file to document what certain parts mean?