Giter Club home page Giter Club logo

Comments (4)

jorgen avatar jorgen commented on July 18, 2024

What version of msvc are you using?
I don't know what is wrong. I wrote a small program to test this out, and it compiled for me:

#include <string>
#include <json_struct.h>

const char json[] = R"json(
{
}
)json";

namespace licmgrapi
{
struct Module
{
  std::string key;
  double value;

  JS_OBJ(key, value);
};


struct Config
    {
        std::string webInterface = "0.0.0.0";
        int webPort = 9898;
        std::string apiKey = "xxxyyyzzz";
        std::string productId = "xxxxxxxxxx";
        std::string productVersion = "0.1";
        std::string licFile = "licfiles\\licfile_9001494765.lic";
        bool useSwagger = false;
        std::string revalidate = "0 */30 * * * ?";
        int thresholdOfflineHours = 48;
        int thresholdValidatedHours = 720;
        int cicoModule = -1;
        std::vector<Module> moduleList;
        Config() {}
        Config(int argc, char* argv[]);
        JS_OBJECT(
            JS_MEMBER(webInterface),
            JS_MEMBER(webPort),
            JS_MEMBER(apiKey),
            JS_MEMBER(productId),
            JS_MEMBER(productVersion),
            JS_MEMBER(licFile),

            JS_MEMBER(useSwagger),
            JS_MEMBER(revalidate),
            JS_MEMBER(thresholdOfflineHours),
            JS_MEMBER(thresholdValidatedHours),
            JS_MEMBER(cicoModule),
            JS_MEMBER(moduleList)
        );
    };
}
int main()
{
    licmgrapi::Config obj;
    JS::ParseContext parseContext(json);
    if (parseContext.parseTo(obj) != JS::Error::NoError)
    {
        std::string errorStr = parseContext.makeErrorString();
        fprintf(stderr, "Error parsing struct %s\n", errorStr.c_str());
        return -1;
    }
    std::string json_string = JS::serializeStruct(obj);
    return 0;
}

from json_struct.

clabnet avatar clabnet commented on July 18, 2024

Thanks for your support.

C++17 on Visual Studio 2019 Toolset 142.

from json_struct.

clabnet avatar clabnet commented on July 18, 2024

"Missing JS_OBJECT JS_OBJECT_EXTERNAL or TypeHandler specialisation\n");

from json_struct.

jorgen avatar jorgen commented on July 18, 2024

Hi,

Turned out I had forgotton to add the TypeHandler for std::shared_ptr. I have updated the master branch to contain this now, and all should be good 👍

from json_struct.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.