title: How can I handle reading a .json file in it that has comments with python?
body: <p>Firstly, I understand that comments aren't valid json. That said, for some reason this .json file I have to process has comments at the start of lines and at the end of lines.</p>
  
  <p>How can i handle this in python and basically load the .json file but ignore the comments so that I can process it? I am currently doing the following:</p>
  
  <pre><code>with open('/home/sam/Lean/Launcher/bin/Debug/config.json', 'r') as f:
          config_data=json.load(f)
  </code></pre>
  
  <p>But this crashes at the json.load(f) command because the file f has comments in it.</p>
  
  <p>I thought this would be a common problem but I can't find much online RE how to handle it in python. Someone suggested commentjson but that makes my script crash saying</p>
  
  <pre><code>ImportError: cannot import name 'dump'
  </code></pre>
  
  <p>When I import commentjson</p>
  
  <p>Thoughts?</p>
  
  <p>Edit:
  Here is a snippet of the json file i must process.</p>
  
  <pre><code>{
    // this configuration file works by first loading all top-level
    // configuration items and then will load the specified environment
    // on top, this provides a layering affect. environment names can be
    // anything, and just require definition in this file. There's
    // two predefined environments, 'backtesting' and 'live', feel free
    // to add more!
  
    "environment": "backtesting",// "live-paper", "backtesting", "live-interactive", "live-interactive-iqfeed"
  
    // algorithm class selector
    "algorithm-type-name": "BasicTemplateAlgorithm",
  
    // Algorithm language selector - options CSharp, FSharp, VisualBasic, Python, Java
    "algorithm-language": "CSharp"
  }
  </code></pre>