<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def encode_to_json(order_or_history):
 """ Given an order or history entry, encode it to JSON and return. :type order_or_history: MarketOrderList or MarketHistoryList :param order_or_history: A MarketOrderList or MarketHistoryList instance to encode to JSON. :rtype: str :return: The encoded JSON string. """

    if isinstance(order_or_history, MarketOrderList):
        return orders.encode_to_json(order_or_history)
    elif isinstance(order_or_history, MarketHistoryList):
        return history.encode_to_json(order_or_history)
    else:
        raise Exception("Must be one of MarketOrderList or MarketHistoryList.")