Some weeks ago, I wrote a little JSON-RPC implemention on my Windows Notebook based on C++ and Qt. I used the Visual C++ 2013 compiler and it worked without any problems.
Now I copied my code to an Linux Mint machine with an GCC compiler and I always get the following error:
jsonrpc.h:18: Error: conversion from 'long int' to 'QJsonValue' is ambiguous
static QJsonObject generateErrorObj(ErrorCode code, QString message, QJsonValue data = NULL);
This error also appears on line 19 (method generateErrorResponse) and line 20 (method generateRequest). So... now I'm not that familiar with C++ or Qt, so I don't get it, why this doesn't work, althought it worked on Windows...
Here is the full code of the jsonrpc.h:
#ifndef JSONRPC_H
#define JSONRPC_H
#include <QtCore>
class JSONRPC
{
public:
enum ErrorCode
{
PARSE_ERROR = -32700,
INVALID_REQUEST = -32600,
METHOD_NOT_FOUND = -32601,
INVALID_PARAMS = -32602,
INTERNAL_ERROR = -32603
};
static QJsonObject generateObj(QString id, bool isNotification = false);
static QJsonObject generateErrorObj(ErrorCode code, QString message, QJsonValue data = NULL);
static QJsonObject generateErrorResponse(QString id, ErrorCode code, QString message, QJsonValue data = NULL);
static QJsonObject generateRequest(QString id, QString method, QJsonValue parameters = NULL, bool isNotification = false);
static QJsonObject generateResponse(QString id, QJsonValue result);
};
#endif // JSONRPC_H