Skip to content

sukai33/yazi-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yazi-json

a tiny c++ json parser

example

main.json

{
    "name": "jack",
    "age": 30,
    "area": ["c++", "php", "python", "go"]
}

main.cpp

#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;

#include "Json.h"
using namespace yazi::json;

int main()
{
    try
    {
        ifstream fin("./main.json");
        stringstream ss;
        ss << fin.rdbuf();
        const string & data = ss.str();

        Json json;
        json.parse(data);
        std::cout << json.str() << std::endl;

        const string & name = json["name"];
        int type = json["age"];
        const string & area = json["area"][0];
        json.clear();
    }
    catch (std::exception & e)
    {
        std::cout << "catch exception: " << e.what() << std::endl;
    }
    return 0;
}

About

a tiny c++ json parser

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published