Parsing JSON array in Python to create a delimited string
Question: Brand new to Python and trying to parse a JSON array like the one below:

    
    
    [
      {"Event":"start","EventDateTime":"2015-09-15T03:45:16.681428Z"},
      {"Event":"process","EventDateTime":"2015-09-15T03:45:16.681428Z"},
      {"Event":"end","EventDateTime":"2015-09-15T03:45:16.681428Z"}
    ]
    

I need the output to be on string tab delimited fields and new line delimted
row, like this:

    
    
    start \t 2015-09-15T03:45:16.681428Z \n
    process \t 2015-09-15T03:45:16.681428Z \n
    end \t 2015-09-15T03:45:16.681428Z 
    

here's the code I have so far:

    
    
              import json
          if not j or not i:
            return None
          try:
            arr = json.loads(j)
          except ValueError:
            return None
          if len(arr) <= 0:
            return None
          row=i
          for li in arr
            elem = json.loads(li, object_pairs_hook=collections.OrderedDict)
            row=row + '\t' + elem.Key + '\t' + elem.Value + \n
          return row
    

First I get, Indent errors, fixed indents but getting error about
'collections' not defined.

Is there a way to do what I need without using that collections. When I remove
the collections object I get other errors.

Thanks!!


Answer: 
    import json    
    
    j = """[
      {"Event":"start","EventDateTime":"2015-09-15T03:45:16.681428Z"},
      {"Event":"process","EventDateTime":"2015-09-15T03:45:16.681428Z"},
      {"Event":"end","EventDateTime":"2015-09-15T03:45:16.681428Z"}
    ]"""
    
    j = json.loads(j)
    for item in j:
        print '%s\t%s' % (item['Event'], item['EventDateTime'])
    

