title: Add "entry" to JSON File with Python
body: <p>I need to modify a JSON-File with python. As I'm working with python (and JSON) for the first time, I read some articles about it, but didn't understand it completely.</p>
  
  <p>I managed to import a JSON to python, as some kind of array (or list?).</p>
  
  <p>JSON looks like this:</p>
  
  <pre><code>{
    "sources":[{
      "id":100012630,
      "name":"Activity Login Page",
      "category":"NAM/Activity",
      "automaticDateParsing":true,
      "multilineProcessingEnabled":false,
      "useAutolineMatching":false,
      "forceTimeZone":true,
      "timeZone":"Europe/Brussels",
      "filters":[],
      "cutoffTimestamp":1414364400000,
      "encoding":"UTF-8",
      "pathExpression":"C:\\NamLogs\\nam-login-page.log*",
      "blacklist":[],
      "sourceType":"LocalFile",
      "alive":true
    },{
      "id":100001824,
      "name":"localWinEvent",
      "category":"NAM/OS/EventLog",
      "automaticDateParsing":true,
      "multilineProcessingEnabled":false,
      "useAutolineMatching":false,
      "forceTimeZone":false,
      "filters":[],
      "cutoffTimestamp":1409090400000,
      "encoding":"UTF-8",
      "logNames":["Security","Application","System","Others"],
      "sourceType":"LocalWindowsEventLog",
      "alive":true
    },{
      "id":100001830,
      "name":"localWinPerf",
      "category":"NAM/OS/Perf",
      "automaticDateParsing":false,
      "multilineProcessingEnabled":false,
      "useAutolineMatching":false,
      "forceTimeZone":false,
      "filters":[],
      "cutoffTimestamp":0,
      "encoding":"UTF-8",
      "interval":60000,
      "wmiQueries":[{
        "name":"NAMID Service",
        "query":"SELECT * FROM Win32_PerfRawData_PerfProc_Process WHERE Name = 'tomcat7'"
      },{
        "name":"CPU",
        "query":"select * from Win32_PerfFormattedData_PerfOS_Processor"
      },{
        "name":"Logical Disk",
        "query":"select * from Win32_PerfFormattedData_PerfDisk_LogicalDisk"
      },{
        "name":"Physical Disk",
        "query":"select * from Win32_PerfFormattedData_PerfDisk_PhysicalDisk"
      },{
        "name":"Memory",
        "query":"select * from Win32_PerfFormattedData_PerfOS_Memory"
      },{
        "name":"Network",
        "query":"select * from Win32_PerfFormattedData_Tcpip_NetworkInterface"
      }],
      "sourceType":"LocalWindowsPerfMon",
      "alive":true
    },
  </code></pre>
  
  <p>Now, as I got hundreds of files like those, I wrote a foreach through the whole directory:</p>
  
  <pre><code>for filename in os.listdir('./json/'):
     with open('./json/'+filename) as data_file:    
     sources = json.load(data_file)
  </code></pre>
  
  <p>Now I would need something like again a foreach source in sources, which adds a row (or a entry or whatever a "line" in JSON is called) to every source (something like collectorName=fileName) and then overwrite the old file with the new one.</p>
  
  <p>The JSON would then look like this:</p>
  
  <pre><code>   {
        "sources":[{
          "id":100012630,
          "name":"Activity Login Page",
          "category":"NAM/Activity",
          "automaticDateParsing":true,
          "multilineProcessingEnabled":false,
          "useAutolineMatching":false,
          "forceTimeZone":true,
          "timeZone":"Europe/Brussels",
          "filters":[],
          "cutoffTimestamp":1414364400000,
          "encoding":"UTF-8",
          "pathExpression":"C:\\NamLogs\\nam-login-page.log*",
          "blacklist":[],
          "sourceType":"LocalFile",
          "alive":true,
          "collectorName":"Collector2910"
        },{
          "id":100001824,
          "name":"localWinEvent",
          "category":"NAM/OS/EventLog",
          "automaticDateParsing":true,
          "multilineProcessingEnabled":false,
          "useAutolineMatching":false,
          "forceTimeZone":false,
          "filters":[],
          "cutoffTimestamp":1409090400000,
          "encoding":"UTF-8",
          "logNames":["Security","Application","System","Others"],
          "sourceType":"LocalWindowsEventLog",
          "alive":true,
          "collectorName":"Collector2910"
        },{.....
  </code></pre>
  
  <p>I hope I could explain my issue and I'd be happy if someone could help me out (even with a totally different solution).</p>
  
  <p>Thanks in advance</p>
  
  <p>Michael</p>