Skip to content

Latest commit

 

History

History
48 lines (32 loc) · 906 Bytes

File metadata and controls

48 lines (32 loc) · 906 Bytes

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;
}