<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def __parse_organizations(self, json):
 """Parse Eclipse organizations. The Eclipse organizations format is a JSON document stored under the "organizations" key. The next JSON shows the structure of the document: { 'organizations' : { '1': { 'active': '2001-01-01 18:00:00', 'id': '1', 'image' : 'http://example.com/image/1', 'inactive' : null, 'isMember': '1', 'name': 'Organization 1', 'url': 'http://example.com/org/1' }, '2': { 'active': '2015-12-31 23:59:59', 'id': '1', 'image' : 'http://example.com/image/2', 'inactive': '2008-01-01 18:00:00', 'isMember': '1', 'name': 'Organization 2', 'url': 'http://example.com/org/2' } } } :param json: JSON object to parse :raises InvalidFormatError: raised when the format of the JSON is not valid. """

        try:
            for organization in json['organizations'].values():
                name = self.__encode(organization['name'])

                try:
                    active = str_to_datetime(organization['active'])
                    inactive = str_to_datetime(organization['inactive'])

                    # Ignore organization
                    if not active and not inactive:
                        continue

                    if not active:
                        active = MIN_PERIOD_DATE
                    if not inactive:
                        inactive = MAX_PERIOD_DATE
                except InvalidDateError as e:
                    raise InvalidFormatError(cause=str(e))

                org = self._organizations.get(name, None)

                if not org:
                    org = Organization(name=name)

                    # Store metadata valid for identities parsing
                    org.active = active
                    org.inactive = inactive

                    self._organizations[name] = org
        except KeyError as e:
            msg = "invalid json format. Attribute %s not found" % e.args
            raise InvalidFormatError(cause=msg)