@classmethod<EOL><INDENT>def json(<EOL>klass,<EOL>map=None,<EOL>allow_404=True,<EOL>one=False,<EOL>decode=False,<EOL>is_id=False,<EOL>index=False):<DEDENT>
def cb(response):<EOL><INDENT>CB._status(response, allow_404=allow_404)<EOL>if response.code == <NUM_LIT>:<EOL><INDENT>return response.headers['<STR_LIT>'], None<EOL><DEDENT>data = json.loads(response.body)<EOL>if decode:<EOL><INDENT>for item in data:<EOL><INDENT>if item.get(decode) is not None:<EOL><INDENT>item[decode] = base64.b64decode(item[decode])<EOL><DEDENT><DEDENT><DEDENT>if is_id:<EOL><INDENT>data = data['<STR_LIT>']<EOL><DEDENT>if one:<EOL><INDENT>if data == []:<EOL><INDENT>data = None<EOL><DEDENT>if data is not None:<EOL><INDENT>data = data[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>if map:<EOL><INDENT>data = map(data)<EOL><DEDENT>if index:<EOL><INDENT>return response.headers['<STR_LIT>'], data<EOL><DEDENT>return data<EOL><DEDENT>return cb<EOL>
*map* is a function to apply to the final result.

*allow_404* if set, None will be returned on 404, instead of raising
NotFound.

*index* if set, a tuple of index, data will be returned.

*one* returns only the first item of the list of items. empty lists are
coerced to None.

*decode* if specified this key will be base64 decoded.

*is_id* only the 'ID' field of the json object will be returned.