def load_metadata(stream):
try:<EOL><INDENT>metadata = json.load(<EOL>stream, encoding='<STR_LIT:utf8>', object_pairs_hook=OrderedDict)<EOL><DEDENT>except json.JSONDecodeError as e:<EOL><INDENT>err = RuntimeError('<STR_LIT>'.format(stream.name, e))<EOL>raise_from(err, e)<EOL><DEDENT>else:<EOL><INDENT>for group in metadata:<EOL><INDENT>if group == '<STR_LIT>':<EOL><INDENT>continue<EOL><DEDENT>apis = metadata[group]['<STR_LIT>']<EOL>for api in apis.values():<EOL><INDENT>int_changelog = OrderedDict()<EOL>for version, log in api.get('<STR_LIT>', {}).items():<EOL><INDENT>int_changelog[int(version)] = log<EOL><DEDENT>api['<STR_LIT>'] = int_changelog<EOL><DEDENT><DEDENT><DEDENT>finally:<EOL><INDENT>stream.close()<EOL><DEDENT>return metadata<EOL>
Load JSON metadata from opened stream.