import json
import collections


def textToJSON(text, orderedDict=True, showErrors=False):
	"""
	Turn a JSON object stored as text into a Python object.
	Will be forced to a Python collections.OrderedDict if orderedDict argument
	is True.
	"""
	try:
		if orderedDict:
			return json.loads(text, object_pairs_hook=collections.OrderedDict)
		else:
			return json.loads(text)
	except:
		if showErrors:
			raise
		else:
			return None