def parse_injection(request, rev_id):
    """Parse values for features / datasources of interest."""
    cache = {}

    if 'inject' in request.values:
        try:
            cache = json.loads(request.values['inject'])
        except json.JSONDecodeError as e:
            raise CacheParsingError(e)

    if rev_id is not None:
        rev_cache = cache

        try:
            for k, v in request.values.items():
                if k.startswith(("feature.", "datasource.")):
                    rev_cache[k] = json.loads(v)
        except json.JSONDecodeError as e:
            raise CacheParsingError(e)

        if len(rev_cache) > 0:
            cache = {rev_id: rev_cache}
    else:
        cache = {int(rev_id): c for rev_id, c in cache.items()}

    return cache or None
Parse values for features / datasources of interest.