title: conversion from class to json using nlohmann in c++
body: <p>I have been trying to convert my class to json in visual studio 2017 but there are linker errors C2440.
  "</p>
  
  <pre><code>Severity    Code    Description Project File    Line    Suppression State
  Error   C2440   'initializing': cannot convert from 'ns::person' to 'nlohmann::basic_json&lt;std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer&gt;'   jason reader writer c:\users\lengdon\source\repos\jason reader writer\jason reader writer\objecttojason.h   15  
  </code></pre>
  
  <p>My code is:
  Class 1:</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;string&gt;
  #include"nlohmann/json.hpp"
  #include"nlohmann/adl_serializer.hpp"
  using namespace std;
  using json = nlohmann::json;
  namespace ns {
      // a simple struct to model a person
      class person {
      public:
          string name;
          string address;
          int age;
          void to_json(json&amp; j, const person&amp; p) {
              j = json{ {"name", p.name}, {"address", p.address}, {"age", p.age} };
          }
          void from_json(const json&amp; j, person&amp; p) {
              j.at("name").get_to(p.name);
              j.at("address").get_to(p.address);
              j.at("age").get_to(p.age);
          }
      };    
  }
  </code></pre>
  
  <p>class 2:</p>
  
  <pre><code>#include"Student.h"
  #include"nlohmann/json.hpp"
  #include"nlohmann/adl_serializer.hpp"
  using json = nlohmann::json;
  using namespace std;
  class ObjectToJason
  {
  public:
      json convert()
      {
          ns::person p{ "Ned Flanders", "744 Evergreen Terrace", 60 };
          json j=p;
  
      }
  };
  </code></pre>
  
  <p>In my code for class 2, json j= has errors "<em>no suitable user defined conversions fron ns::person to json exist</em>".
  I am new to c++ and json so please try to explain in plain English. Thank you in advance</p>