8000 GitHub - mitsuakki/jdaughter: Like JSON, but rebellious enough to talk back.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

mitsuakki/jdaughter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jdaughter

A lightweight C++ header-only wrapper around nlohmann/json that supports JSON files with comments.

Features

  • Supports single-line (//) and multi-line (/* ... */) comments.
  • Strips comments safely without removing string content.
  • Easy to use as a drop-in replacement for nlohmann::json::parse.

Usage

#include <iostream>
#include <string>
#include "jdaughter.hpp"

int main(int argc, char* argv[]) {
    if (argc < 2) {
        std::cerr << "Usage: " << argv[0] << " <json_file>" << std::endl;
        return 1;
    }

    std::string filename = argv[1];
    auto j = jdaughter::parse_file(filename);
    if (j.is_null()) {
        std::cerr << "Error parsing JSON: Could not open file: " << filename << std::endl;
        return 1;
    }

    for (const auto& user : j.at("users")) {
        std::cout << "- ID: " << user.at("id").get<std::string>() << "\n";
        std::cout << "  Name: " << user.at("name").get<std::string>() << "\n";
        std::cout << "  Email: " << user.at("email").get<std::string>() << "\n";
        std::cout << "  Role: " << user.at("role").get<std::string>() << "\n\n";
    }

    return 0;
}

About

Like JSON, but rebellious enough to talk back.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0