# 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
			raise DecodeError(u'HAL links must be JSON objects.')
		if not isinstance(self['_embedded'], dict):
			raise DecodeError(u'HAL embedded must be JSON objects.')

	@property
	def self(self):
		return self.expand(self.get_link('self')['href'])

	def get_links(self, relation, name=None):
		links = self['_links'].get(relation)
		if links is None:
			return
		if isinstance(links, dict):
			links = [links]
		if not isinstance(links, (list, tuple)):
			raise DecodeError(u'HAL links must be arrays or objects')
		for link in links:
			if not isinstance(link, dict):
				raise DecodeError(u'HAL link must be object')
			if not isinstance(link.get('href'), string_types):
				raise DecodeError(u'HAL links must contain href')
			if name is not None and link.get('name') != name:
				continue
			link.setdefault('templated', False)
			link.setdefault('deprecation', False)
			link.setdefault('name', None)
			link.setdefault('type', None)
			link.setdefault('profile', None)
			link.setdefault('hreflang', None)
			for key in ('name', 'type', 'profile', 'hreflang'):

# 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

			raise DecodeError(u'HAL links must be JSON objects.')
		if not isinstance(self['_embedded'], dict):
			raise DecodeError(u'HAL embedded must be JSON objects.')

	@property
	def self(self):
		return self.expand(self.get_link('self')['href'])

	def get_links(self, relation, name=None):
		links = self['_links'].get(relation)
		if links is None:
			return
		if isinstance(links, dict):
			links = [links]
		if not isinstance(links, (list, tuple)):
			raise DecodeError(u'HAL links must be arrays or objects')
		for link in links:
			if not isinstance(link, dict):
				raise DecodeError(u'HAL link must be object')
			if not isinstance(link.get('href'), string_types):
				raise DecodeError(u'HAL links must contain href')
			if name is not None and link.get('name') != name:
				continue
			link.setdefault('templated', False)
			link.setdefault('deprecation', False)
			link.setdefault('name', None)
			link.setdefault('type', None)
			link.setdefault('profile', None)
			link.setdefault('hreflang', None)
			for key in ('name', 'type', 'profile', 'hreflang'):

				if not isinstance(link[key], string_types):