netheril96 / StaticJSON

Fast, direct and static typed parsing of JSON with C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Duplicate key in map

imtrobin opened this issue · comments

Hi, I'm testing with a map , I did not set AllowDuplicatekey, but it did not return an error. e.g the json has 3 items, but it read 2 sucessfully.

struct Map
{
  std::map <string, string>  m;

	void	staticjson_init (staticjson::ObjectHandler* h)
	{
		h->add_property ("Map", &m);
		h->set_flags (staticjson::Flags::DisallowUnknownKey);
	}
}
{
 "Map": 
 {
 "one": { "x":"onedata"},
 "two" : { "x":"twodata"},
 "two" : { "x":"this is not taken"}
 }
}

AllowDuplicateKey only works for the keys of the object itself. map does not report error on duplicate key. multimap collects all duplicated ones.

ok noted, thanks.