Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How To Use

Require C++20

Example

#include <iostream>
#include <pfrjson/pfrjson.h>

struct Sub {
    string sub;
};

struct Root {
    int a{};
    double b{};
    string c;
    bool d{};
    Sub sub;
    optional<Sub> nullsub;
    optional<Sub> opsub;
};

int main() {
    // Prepare data to serialize
    Root root{
        1,
        2.5,
        "Test C++",
        false,
        {
            "This is Sub."
        },
        nullopt,
        Sub{
            "That's good"
        }
    };
    
    // Serialize to json
    string json_str = PfrJson::serialize<RP::PrettyWriter<RP::StringBuffer>>(root);
    cout << json_str << endl;
    
    // Prepare deserialize slot
    Root desc;
    
    // Deserialize json
    PfrJson::deserialize(json_str, desc);
    cout << desc.sub.sub << endl;
}

About

An easy use C++ json library.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages