Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error using json.dump(); #1081

Closed
Jerajo opened this issue May 7, 2018 · 1 comment
Closed

Error using json.dump(); #1081

Jerajo opened this issue May 7, 2018 · 1 comment

Comments

@Jerajo
Copy link

Jerajo commented May 7, 2018

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

@Jerajo
Copy link
Author

Jerajo commented May 7, 2018

I do apology for the inconvenience.
I solve the issue was that I was calling the function as char* when I declared it string.

@Jerajo Jerajo closed this as completed May 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant