import re
import json


def read_json (filename) :
    """
    Comments in the form of
        # rest of line
    are stripped from json before parsing

    use like this::

        import pprint
        pprint.pprint (read_json (sys.argv[1]))

    """

    with open (filename) as f:

        content = ''

        # weed out comments
        for line in f.readlines () :
            content += re.sub (r'^\s*#.*', '', line)

        return json.loads (content)