human
Can you provide a the Python code you requested given the following:
Complete the below
def expect_json(view_function):

    ''''View decorator for simplifying handing of requests that expect json.  If the request\'s
    CONTENT_TYPE is application/json, parses the json dict from request.body, and updates
    request.POST with the contents.'
    '''
assistant
#Here is the Python code you requested.
    @wraps(view_function)
    def parse_json_into_request(request, *args, **kwargs):
        if (('application/json' in request.META.get('CONTENT_TYPE', '')) and request.body):
            try:
                request.json = json.loads(request.body)
            except ValueError:
                return JsonResponseBadRequest({'error': 'Invalid    JSON'})
        else:
            request.json = {}
        return view_function(request, *args, **kwargs)
    return parse_json_into_request