# Path: httoop/codecs/application/json.py
# class JSON(Codec):
# 	mimetype = 'application/json'
# 
# 	@classmethod
# 	def encode(cls, data, charset=None, mimetype=None):
# 		data = json_encode(data)
# 		if not isinstance(data, bytes):  # python3
# 			data = data.encode(charset or 'UTF-8')
# 		return data
# 
# 	@classmethod
# 	def decode(cls, data, charset=None, mimetype=None):
# 		return json_decode(data.decode(charset or 'ASCII'))
# 
# Path: httoop/exceptions.py
# class DecodeError(_Translateable, ValueError):
# 	u"""error raised when decoding failed"""
# 
# class EncodeError(_Translateable, ValueError):
# 	u"""error raised when encoding failed"""
# 
# Path: httoop/six.py



	from uritemplate import expand
from httoop.codecs.application.json import JSON
from httoop.exceptions import DecodeError, EncodeError
from httoop.six import string_types
		if not isinstance(links, list):
			links = [links]
		links.append(link)
		self['_links'][relation] = links
		self['_links'][relation] = list(self.get_links(relation))

	def add_resource(self, relation, resource):
		resources = list(self.get_resources(relation))
		resources.append(resource)
		self['_embedded'][relation] = resources


class HAL(JSON):
	mimetype = 'application/hal+json'

	@classmethod
	def decode(cls, data, charset=None, mimetype=None):
		data = super(HAL, cls).decode(data)
		if not isinstance(data, dict):
			raise DecodeError(u'HAL documents must be JSON objects.')
		return Resource(data)

	@classmethod
	def encode(cls, data, charset=None, mimetype=None):
		if not isinstance(data, dict):
			raise EncodeError(u'HAL documents must be JSON objects.')

		try:
			Resource(data.copy())
		except DecodeError as exc:

# Path: httoop/codecs/application/json.py
# class JSON(Codec):
# 	mimetype = 'application/json'
# 
# 	@classmethod
# 	def encode(cls, data, charset=None, mimetype=None):
# 		data = json_encode(data)
# 		if not isinstance(data, bytes):  # python3
# 			data = data.encode(charset or 'UTF-8')
# 		return data
# 
# 	@classmethod
# 	def decode(cls, data, charset=None, mimetype=None):
# 		return json_decode(data.decode(charset or 'ASCII'))
# 
# Path: httoop/exceptions.py
# class DecodeError(_Translateable, ValueError):
# 	u"""error raised when decoding failed"""
# 
# class EncodeError(_Translateable, ValueError):
# 	u"""error raised when encoding failed"""
# 
# Path: httoop/six.py



# Path: httoop/codecs/application/hal_json.py
	from uritemplate import expand
from httoop.codecs.application.json import JSON
from httoop.exceptions import DecodeError, EncodeError
from httoop.six import string_types

		if not isinstance(links, list):
			links = [links]
		links.append(link)
		self['_links'][relation] = links
		self['_links'][relation] = list(self.get_links(relation))

	def add_resource(self, relation, resource):
		resources = list(self.get_resources(relation))
		resources.append(resource)
		self['_embedded'][relation] = resources


class HAL(JSON):
	mimetype = 'application/hal+json'

	@classmethod
	def decode(cls, data, charset=None, mimetype=None):
		data = super(HAL, cls).decode(data)
		if not isinstance(data, dict):
			raise DecodeError(u'HAL documents must be JSON objects.')
		return Resource(data)

	@classmethod
	def encode(cls, data, charset=None, mimetype=None):
		if not isinstance(data, dict):
			raise EncodeError(u'HAL documents must be JSON objects.')

		try:
			Resource(data.copy())
		except DecodeError as exc:

			raise EncodeError(str(exc))