Skip to content

map which contain a string as key fail to convert if the key is a number #177

@Wawha

Description

@Wawha

Take a std::map<std::string, double>. If you create a javascript map with this pair { "0": 3.1415 }, the conversion from v8 type to C++ map with fail, because the key "0" is store as number 0 in javascript.
In my case, I have this problem because I create a C++ map with a string key (with a just number), return that map in a function bind in javascript, and then retrieve that value inside another function.

I try locally this fix inside convert<String, ...> inside convert.hpp, and it seems to work great:

	static bool is_valid(v8::Isolate*, v8::Local<v8::Value> value)
	{
		return !value.IsEmpty() && (value->IsString() || value->IsNumber());
	}

In case you prefer/require a Pull requests to fix that bug, I can try to do it with the right unit test.

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