Skip to content

NaN problem within develop branch #693

Description

@zenfey

Library json is a very nice and foregoing work.

I noticed that develop branch made effort on the bug of NaN and INF problem. however after deserialization of a serialized json object containing nan, an exception is throwed. binary serialization works fine.

#include <json.hpp>
#include <vector>
#include <iostream>

using json =  nlohmann::json;

int main() {

	std::vector<double> a;
	a.push_back(std::numeric_limits<double>::quiet_NaN());
	a.push_back(2);
	json j;
	j["vec"] = a;
	j["number"] = std::numeric_limits<double>::quiet_NaN();

	std::string strj = j.dump();

	json j2 = json::parse(strj);

	std::vector<double> b = j2["vec"];
	std::cout << b[0] << std::endl;
	double n = j2["number"];
	std::cout << n << std::endl;
	
	return 0;
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions