Skip to content

ratioSolver/json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON

This repository contains a JSON parser and generator written in C++.

Read a JSON from a string

#include "json.hpp"
#include <iostream>

int main()
{
    std::string json_string = "{\"key\": \"value\"}";
    json::json j = json::load(json_string);
    std::cout << j["key"] << std::endl;
    return 0;
}

Write a JSON to a string

#include "json.hpp"
#include <iostream>

int main()
{
    json::json j;
    j["key"] = "value";
    j["number"] = 42;
    j["array"] = {1, 2, 3};
    j["object"] = {{"key", "value"}};
    std::cout << j.dump() << std::endl;
    return 0;
}

About

A very simple JSON library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published