<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def from_json(stream, cls=None, object_pairs_hook=OrderedDict, **extras):
 """ Convert a JSON string or stream into specified class. """

    stream = stream.read() if hasattr(stream, 'read') else stream
    json_dict = json.loads(stream, object_pairs_hook=object_pairs_hook)
    if extras:
        json_dict.update(extras)  # pragma: no cover
    return to_model(cls, json_dict) if cls else json_dict