Skip to content

Error using json.dump(); #1081

@Jerajo

Description

@Jerajo

I'm using visual studio and I got this error. on the xutility file

Exception thrown: write access violation.
this was 0xAFE3D714.

I'm doing a "C" compatible DLL in C++. Here is the code:

#define gmx extern "C" __declspec(dllexport)
using json = nlohmann::json;

static json jsonDoc;

gmx double read(char* path) {
	try
	{
		ifstream jsonFile(path);
		jsonFile >> jsonDoc;
	}
	catch (const std::exception& error)
	{
		cout << error.what() << endl;
	}
	return 0;
}

gmx string getJsonFile() {
	return jsonDoc.dump();
}

Then I implement it like this.

_read(file);
string output = _getJsonFile();
cout << output.c_str();

I don't know what I doing wrong. I hope someone can help me.

windows 10 x86 Visual Studio 2017 (v141):
print screen:
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions