from typing import OrderedDict


def save_chain(config, chain):
	"""
		Encode a chain of operation classes as json.

		:param config: dictionary with settings.
		:param chain: OrderedDict of operation class lists.
		:return: string-encoded version of the above.
	"""
	di = OrderedDict()
	di['__config__'] = config
	for key, ops in chain.items():
		di[key] = [op.to_json() for op in ops]
	return di
	#return dumps(di, indent = 2)