title: Convert string lines to valid json format in Python
body: <p>Given a <code>test.json</code> file with content as follows:</p>
  <pre><code>{'review/appearance': 2.5, 'beer/style': 'Hefeweizen', 'review/palate': 1.5, 'review/taste': 1.5, 'beer/name': 'Sausa Weizen', 'review/timeUnix': 1234817823, 'beer/ABV': 5.0, 'beer/beerId': '47986', 'beer/brewerId': '10325', 'review/timeStruct': {'isdst': 0, 'mday': 16, 'hour': 20, 'min': 57, 'sec': 3, 'mon': 2, 'year': 2009, 'yday': 47, 'wday': 0}, 'review/overall': 1.5, 'review/text': 'A lot of foam. But a lot.\tIn the smell some banana, and then lactic and tart. Not a good start.\tQuite dark orange in color, with a lively carbonation (now visible, under the foam).\tAgain tending to lactic sourness.\tSame for the taste. With some yeast and banana.', 'user/profileName': 'stcules', 'review/aroma': 2.0}
  {'review/appearance': 3.0, 'beer/style': 'English Strong Ale', 'review/palate': 3.0, 'review/taste': 3.0, 'beer/name': 'Red Moon', 'review/timeUnix': 1235915097, 'beer/ABV': 6.2, 'beer/beerId': '48213', 'beer/brewerId': '10325', 'review/timeStruct': {'isdst': 0, 'mday': 1, 'hour': 13, 'min': 44, 'sec': 57, 'mon': 3, 'year': 2009, 'yday': 60, 'wday': 6}, 'review/overall': 3.0, 'review/text': 'Dark red color, light beige foam, average.\tIn the smell malt and caramel, not really light.\tAgain malt and caramel in the taste, not bad in the end.\tMaybe a note of honey in teh back, and a light fruitiness.\tAverage body.\tIn the aftertaste a light bitterness, with the malt and red fruit.\tNothing exceptional, but not bad, drinkable beer.', 'user/profileName': 'stcules', 'review/aroma': 2.5}
  {'review/appearance': 3.0, 'beer/style': 'Foreign / Export Stout', 'review/palate': 3.0, 'review/taste': 3.0, 'beer/name': 'Black Horse Black Beer', 'review/timeUnix': 1235916604, 'beer/ABV': 6.5, 'beer/beerId': '48215', 'beer/brewerId': '10325', 'review/timeStruct': {'isdst': 0, 'mday': 1, 'hour': 14, 'min': 10, 'sec': 4, 'mon': 3, 'year': 2009, 'yday': 60, 'wday': 6}, 'review/overall': 3.0, 'review/text': 'Almost totally black. Beige foam, quite compact, not bad.\tLight smell, just a bit of roast, and some hop. A bit too light.\tThe taste is light oo, and drinkable, with some malt, roast, hints of coffee.\tNothing exceptional, but after all drinkable and pleasant.\tLight to average body.\tIn the aftertaste some dust, somr roast, hint of caramel, and a bit of bitterness.\tNo defect, drinkable, not bad.', 'user/profileName': 'stcules', 'review/aroma': 2.5}
  {'review/appearance': 3.5, 'beer/style': 'German Pilsener', 'review/palate': 2.5, 'review/taste': 3.0, 'beer/name': 'Sausa Pils', 'review/timeUnix': 1234725145, 'beer/ABV': 5.0, 'beer/beerId': '47969', 'beer/brewerId': '10325', 'review/timeStruct': {'isdst': 0, 'mday': 15, 'hour': 19, 'min': 12, 'sec': 25, 'mon': 2, 'year': 2009, 'yday': 46, 'wday': 6}, 'review/overall': 3.0, 'review/text': 'Golden yellow color. White, compact foam, quite creamy. Good appearance.\tFresh smell, with good hop. Quite dry, with a good grassy note. Hay. Fresh and pleasant.\tMore sweet in the mouth, with honey. The hop comes back in the end, and in the aftertaste.\tNot bad, but a bit too sweet for a pils.\tIn the end some vanilla and camomile note.\tIn the aftertaste, too. Though the hop, a bit too sweet.\tHonest.', 'user/profileName': 'stcules', 'review/aroma': 3.0}
  {'review/appearance': 4.0, 'beer/style': 'American Double / Imperial IPA', 'review/palate': 4.0, 'review/taste': 4.5, 'beer/name': 'Cauldron DIPA', 'review/timeUnix': 1293735206, 'user/gender': 'Male', 'user/birthdayRaw': 'Jun 16, 1901', 'beer/ABV': 7.7, 'beer/beerId': '64883', 'user/birthdayUnix': -2163081600, 'beer/brewerId': '1075', 'review/timeStruct': {'isdst': 0, 'mday': 30, 'hour': 18, 'min': 53, 'sec': 26, 'mon': 12, 'year': 2010, 'yday': 364, 'wday': 3}, 'user/ageInSeconds': 3581417047, 'review/overall': 4.0, 'review/text': &quot;According to the website, the style for the Caldera Cauldron changes every year. The current release is a DIPA, which frankly is the only cauldron I'm familiar with (it was an IPA/DIPA the last time I ordered a cauldron at the horsebrass several years back). In any event... at the Horse Brass yesterday.\t\tThe beer pours an orange copper color with good head retention and lacing. The nose is all hoppy IPA goodness, showcasing a huge aroma of dry citrus, pine and sandlewood. The flavor profile replicates the nose pretty closely in this West Coast all the way DIPA. This DIPA is not for the faint of heart and is a bit much even for a hophead like myslf. The finish is quite dry and hoppy, and there's barely enough sweet malt to balance and hold up the avalanche of hoppy bitterness in this beer. Mouthfeel is actually fairly light, with a long, persistentely bitter finish. Drinkability is good, with the alcohol barely noticeable in this well crafted beer. Still, this beer is so hugely hoppy/bitter, it's really hard for me to imagine ordering more than a single glass. Regardless, this is a very impressive beer from the folks at Caldera.&quot;, 'user/profileName': 'johnmichaelsen', 'review/aroma': 4.5}
  </code></pre>
  <p>How could I convert it to standard json format? Thanks.</p>
  <p>My trial:</p>
  <pre><code>import json
  
  with open('./test.json','r') as f:
      s = f.read()
      s = s.replace('\t','')
      s = s.replace('\n','')
      s = s.replace(&quot;\'&quot;, &quot;\&quot;&quot;)
      data = json.load(s)
      print(s)
  </code></pre>
  <p>Output:</p>
  <pre><code>AttributeError: 'str' object has no attribute 'read'
  </code></pre>
  <p>Expected result:</p>
  <pre><code>[{&quot;review/appearance&quot;: 2.5, &quot;beer/style&quot;: &quot;Hefeweizen&quot;, &quot;review/palate&quot;: 1.5, &quot;review/taste&quot;: 1.5, &quot;beer/name&quot;: &quot;Sausa Weizen&quot;, &quot;review/timeUnix&quot;: 1234817823, &quot;beer/ABV&quot;: 5.0, &quot;beer/beerId&quot;: &quot;47986&quot;, &quot;beer/brewerId&quot;: &quot;10325&quot;, &quot;review/timeStruct&quot;: {&quot;isdst&quot;: 0, &quot;mday&quot;: 16, &quot;hour&quot;: 20, &quot;min&quot;: 57, &quot;sec&quot;: 3, &quot;mon&quot;: 2, &quot;year&quot;: 2009, &quot;yday&quot;: 47, &quot;wday&quot;: 0}, &quot;review/overall&quot;: 1.5, &quot;review/text&quot;: &quot;A lot of foam. But a lot.\tIn the smell some banana, and then lactic and tart. Not a good start.\tQuite dark orange in color, with a lively carbonation (now visible, under the foam).\tAgain tending to lactic sourness.\tSame for the taste. With some yeast and banana.&quot;, &quot;user/profileName&quot;: &quot;stcules&quot;, &quot;review/aroma&quot;: 2.0},
  {&quot;review/appearance&quot;: 3.0, &quot;beer/style&quot;: &quot;English Strong Ale&quot;, &quot;review/palate&quot;: 3.0, &quot;review/taste&quot;: 3.0, &quot;beer/name&quot;: &quot;Red Moon&quot;, &quot;review/timeUnix&quot;: 1235915097, &quot;beer/ABV&quot;: 6.2, &quot;beer/beerId&quot;: &quot;48213&quot;, &quot;beer/brewerId&quot;: &quot;10325&quot;, &quot;review/timeStruct&quot;: {&quot;isdst&quot;: 0, &quot;mday&quot;: 1, &quot;hour&quot;: 13, &quot;min&quot;: 44, &quot;sec&quot;: 57, &quot;mon&quot;: 3, &quot;year&quot;: 2009, &quot;yday&quot;: 60, &quot;wday&quot;: 6}, &quot;review/overall&quot;: 3.0, &quot;review/text&quot;: &quot;Dark red color, light beige foam, average.\tIn the smell malt and caramel, not really light.\tAgain malt and caramel in the taste, not bad in the end.\tMaybe a note of honey in teh back, and a light fruitiness.\tAverage body.\tIn the aftertaste a light bitterness, with the malt and red fruit.\tNothing exceptional, but not bad, drinkable beer.&quot;, &quot;user/profileName&quot;: &quot;stcules&quot;, &quot;review/aroma&quot;: 2.5},
  {&quot;review/appearance&quot;: 3.0, &quot;beer/style&quot;: &quot;Foreign / Export Stout&quot;, &quot;review/palate&quot;: 3.0, &quot;review/taste&quot;: 3.0, &quot;beer/name&quot;: &quot;Black Horse Black Beer&quot;, &quot;review/timeUnix&quot;: 1235916604, &quot;beer/ABV&quot;: 6.5, &quot;beer/beerId&quot;: &quot;48215&quot;, &quot;beer/brewerId&quot;: &quot;10325&quot;, &quot;review/timeStruct&quot;: {&quot;isdst&quot;: 0, &quot;mday&quot;: 1, &quot;hour&quot;: 14, &quot;min&quot;: 10, &quot;sec&quot;: 4, &quot;mon&quot;: 3, &quot;year&quot;: 2009, &quot;yday&quot;: 60, &quot;wday&quot;: 6}, &quot;review/overall&quot;: 3.0, &quot;review/text&quot;: &quot;Almost totally black. Beige foam, quite compact, not bad.\tLight smell, just a bit of roast, and some hop. A bit too light.\tThe taste is light oo, and drinkable, with some malt, roast, hints of coffee.\tNothing exceptional, but after all drinkable and pleasant.\tLight to average body.\tIn the aftertaste some dust, somr roast, hint of caramel, and a bit of bitterness.\tNo defect, drinkable, not bad.&quot;, &quot;user/profileName&quot;: &quot;stcules&quot;, &quot;review/aroma&quot;: 2.5},
  {&quot;review/appearance&quot;: 3.5, &quot;beer/style&quot;: &quot;German Pilsener&quot;, &quot;review/palate&quot;: 2.5, &quot;review/taste&quot;: 3.0, &quot;beer/name&quot;: &quot;Sausa Pils&quot;, &quot;review/timeUnix&quot;: 1234725145, &quot;beer/ABV&quot;: 5.0, &quot;beer/beerId&quot;: &quot;47969&quot;, &quot;beer/brewerId&quot;: &quot;10325&quot;, &quot;review/timeStruct&quot;: {&quot;isdst&quot;: 0, &quot;mday&quot;: 15, &quot;hour&quot;: 19, &quot;min&quot;: 12, &quot;sec&quot;: 25, &quot;mon&quot;: 2, &quot;year&quot;: 2009, &quot;yday&quot;: 46, &quot;wday&quot;: 6}, &quot;review/overall&quot;: 3.0, &quot;review/text&quot;: &quot;Golden yellow color. White, compact foam, quite creamy. Good appearance.\tFresh smell, with good hop. Quite dry, with a good grassy note. Hay. Fresh and pleasant.\tMore sweet in the mouth, with honey. The hop comes back in the end, and in the aftertaste.\tNot bad, but a bit too sweet for a pils.\tIn the end some vanilla and camomile note.\tIn the aftertaste, too. Though the hop, a bit too sweet.\tHonest.&quot;, &quot;user/profileName&quot;: &quot;stcules&quot;, &quot;review/aroma&quot;: 3.0},
  {&quot;review/appearance&quot;: 4.0, &quot;beer/style&quot;: &quot;American Double / Imperial IPA&quot;, &quot;review/palate&quot;: 4.0, &quot;review/taste&quot;: 4.5, &quot;beer/name&quot;: &quot;Cauldron DIPA&quot;, &quot;review/timeUnix&quot;: 1293735206, &quot;user/gender&quot;: &quot;Male&quot;, &quot;user/birthdayRaw&quot;: &quot;Jun 16, 1901&quot;, &quot;beer/ABV&quot;: 7.7, &quot;beer/beerId&quot;: &quot;64883&quot;, &quot;user/birthdayUnix&quot;: -2163081600, &quot;beer/brewerId&quot;: &quot;1075&quot;, &quot;review/timeStruct&quot;: {&quot;isdst&quot;: 0, &quot;mday&quot;: 30, &quot;hour&quot;: 18, &quot;min&quot;: 53, &quot;sec&quot;: 26, &quot;mon&quot;: 12, &quot;year&quot;: 2010, &quot;yday&quot;: 364, &quot;wday&quot;: 3}, &quot;user/ageInSeconds&quot;: 3581417047, &quot;review/overall&quot;: 4.0, &quot;review/text&quot;: &quot;According to the website, the style for the Caldera Cauldron changes every year. The current release is a DIPA, which frankly is the only cauldron I'm familiar with (it was an IPA/DIPA the last time I ordered a cauldron at the horsebrass several years back). In any event... at the Horse Brass yesterday.\t\tThe beer pours an orange copper color with good head retention and lacing. The nose is all hoppy IPA goodness, showcasing a huge aroma of dry citrus, pine and sandlewood. The flavor profile replicates the nose pretty closely in this West Coast all the way DIPA. This DIPA is not for the faint of heart and is a bit much even for a hophead like myslf. The finish is quite dry and hoppy, and there's barely enough sweet malt to balance and hold up the avalanche of hoppy bitterness in this beer. Mouthfeel is actually fairly light, with a long, persistentely bitter finish. Drinkability is good, with the alcohol barely noticeable in this well crafted beer. Still, this beer is so hugely hoppy/bitter, it's really hard for me to imagine ordering more than a single glass. Regardless, this is a very impressive beer from the folks at Caldera.&quot;, &quot;user/profileName&quot;: &quot;johnmichaelsen&quot;, &quot;review/aroma&quot;: 4.5}]
  </code></pre>