Do not dump an empty list of attrbutes.

pull/34/head
Raphaël Vinot 2016-10-10 12:23:03 +02:00
parent b6072f7145
commit 8817674dd0
1 changed files with 4 additions and 2 deletions

View File

@ -311,7 +311,8 @@ class MISPEvent(object):
if self.Tag:
to_return['Event']['Tag'] = self.Tag
to_return['Event'] = _int_to_str(to_return['Event'])
to_return['Event']['Attribute'] = [a._json() for a in self.attributes]
if self.attributes:
to_return['Event']['Attribute'] = [a._json() for a in self.attributes]
jsonschema.validate(to_return, self.json_schema)
return to_return
@ -338,7 +339,8 @@ class MISPEvent(object):
if self.timestamp:
to_return['Event']['timestamp'] = int(time.mktime(self.timestamp.timetuple()))
to_return['Event'] = _int_to_str(to_return['Event'])
to_return['Event']['Attribute'] = [a._json_full() for a in self.attributes]
if self.attributes:
to_return['Event']['Attribute'] = [a._json_full() for a in self.attributes]
jsonschema.validate(to_return, self.json_schema)
return to_return