title: Creating a json output in python
body: <p>I am trying to return a response for a function in json form. The output is a list with each element being a dictionary. I don't see any mistake when I print the output. The problem arises when I iterate through the output. I get all the characters in the output one by one. See the sample code and sample output for proper understanding.</p>
  
  <p>code:</p>
  
  <pre><code>import requests
  import json
  import sys
  from bs4 import BeautifulSoup
  from collections import OrderedDict
  
  class Cricbuzz():
      url = "http://synd.cricbuzz.com/j2me/1.0/livematches.xml"
      def __init__(self):
          pass
  
      def getxml(self,url):
          try:
              r = requests.get(url)
          except requests.exceptions.RequestException as e: 
              print e
              sys.exit(1)
          soup = BeautifulSoup(r.text,"html.parser")
          return soup
  
      def matchinfo(self,match):
          d = OrderedDict()
          d['id'] = match['id']
          d['srs'] = match['srs']
          d['mchdesc'] = match['mchdesc']
          d['mnum'] = match['mnum']
          d['type'] = match['type']
          d['mchstate'] = match.state['mchstate']
          d['status'] = match.state['status']
          return d
  
      def matches(self):
          xml = self.getxml(self.url)
          matches = xml.find_all('match')
          info = []
          for match in matches:
              info.append(self.matchinfo(match))
          data = json.dumps(info)
          return data 
  c = Cricbuzz()
  matches = c.matches()
  print matches #print matches -  output1
  for match in matches:
      print match #print match -  output2
  </code></pre>
  
  <p>"print matches" i.e output1 in above code gives me following output:</p>
  
  <pre><code>[
      {
          "status": "Coming up on Dec 24 at 01:10 GMT", 
          "mchstate": "nextlive", 
          "mchdesc": "AKL vs WEL", 
          "srs": "McDonalds Super Smash, 2016-17", 
          "mnum": "18TH MATCH", 
          "type": "ODI", 
          "id": "0"
      }, 
      {
          "status": "Ind U19 won by 34 runs", 
          "mchstate": "Result", 
          "mchdesc": "INDU19 vs SLU19", 
          "srs": "Under 19 Asia Cup, 2016", 
          "mnum": "Final", 
          "type": "ODI", 
          "id": "17727"
      }, 
      {
          "status": "PRS won by 48 runs", 
          "mchstate": "Result", 
          "mchdesc": "PRS vs ADS", 
          "srs": "Big Bash League, 2016-17", 
          "mnum": "5th Match", 
          "type": "T20", 
          "id": "16729"
      }
  ]
  </code></pre>
  
  <p>But "print match" i.e output2 in above code inside the for loop gives this output:</p>
  
  <pre><code>[
      {
      "
      i
      d
      "
      :
  
      "
      0
      "
      ,
  
      "
      s
      r
      s
      "
      :
  
      "
      M
      c
      D
      o
      n
      a
      l
      d
      s
  
      S
      u
      p
      e
      r
  
      S
      m
      a
      s
      h
      ,
  
      2
      0
      1
      6
      -
      1
      7
      "
      ,
  
      "
      m
      c
      h
      d
      e
      s
  </code></pre>
  
  <p>As you can see,a character gets printed on each line from matches. I would like to get the dictionary object when printing the match. </p>