Skip to content

trading-rs/derive-json-cpp

Repository files navigation

Automatically generate JSON serializers and deserializers

Build Status

Getting Started

Prerequisite

git submodule update --init --recursive

Build and Test

./build.sh

Examples

#include <derivejson/derivejson.hpp>

#include <json.hpp>
using json = nlohmann::json;

#include <iostream>
#include <string>
using namespace std;

namespace vin {
  DEFINE_MODEL(Vin, (string, transaction_id, "txid")(int, vout, "vout")) 
}

int main(int argc, char** argv) {
  using namespace vin;

  json j = json::parse("{\"txid\":\"0x12312\",\"vout\":3}");
  Vin vin_deserialize = j;

  cout << vin_deserialize.transaction_id << endl;
  cout << vin_deserialize.vout << endl;

  json j_serialize = vin_deserialize;
  cout << j_serialize.dump() << endl;
}

About

Auto generate Serialization / Deserialization instances for https://github.com/nlohmann/json

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published