Skip to content
/ json Public

[de]Serializes any json object or value to a C++ type with the magic of compile time reflection.

License

Notifications You must be signed in to change notification settings

cpp-pre/json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pipeline status for win10, macOS & linux.

pre::from_ or to_ json

[de]Serializes any json object or value to a C++ type with the magic of compile time reflection.

Examples

See :

#include <iostream>
#include <pre/json/from_json.hpp> 

// Your C++ type
struct customer {
  std::string name;
  size_t money_spent; 
  std::vector<std::string> interests;
};

// Reflection for the fields you want to load from json
BOOST_FUSION_ADAPT_STRUCT(customer,
  name,
  money_spent,
  interests)

...

std::string string_from_network = 
  "{\"interests\":[\"sport articles\"], \"money_spent\":50, \"name\":\"Mrs. Fraulein\"}";

// Here you get your C++ type
customer my_customer =
  pre::json::from_json<customer>(string_from_network);

std::cout << "Customer " << my_customer.name << " spent " <<
  my_customer.money_spent << std::endl;

Supported types

License

Boost Software License.

Please give copyright notice :

Copyright (c) 2012-2018 Damien Buhl alias daminetreg ([email protected])

About

[de]Serializes any json object or value to a C++ type with the magic of compile time reflection.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages