title: How to write the results from output in robotframework to csv in dict format using python?
body: <p>I have a robot framework code that has multiple test cases with results. Now I need to store these results in JSON file in key-value pairs using python code. How can I do it?</p>
  
  <p>Pythoncode.py</p>
  
  <pre><code>def writeJson(data):
      with open("data_file.json", "w") as write_file:
         json.dump(data, write_file)
  
  
  Robot Code.robot
  
  
    TC1
     ${output}=    TC1test
     ${dict1}=    Set Variable     ${output}
     ${value_cnt}=    Get Length    ${dict1}
     ${var}=    set variable    ${dict1}
  
     TC2
     ${output}=   TC2test
      ${dict3}=    set variable    ${output}
     ${cnt}=    Get Length    ${dict3}
     ${var}=    set variable    ${dict3}
           : FOR    ${item}    IN RANGE   0    ${cnt}
           \    ${var2}=    Set Variable     ${var['value']} 
  
     write data
     ${json} =      writeJson         ${var1}   \n  ${var2}
  </code></pre>
  
  <p>Output:
  datafile.json
  only one value prints</p>
  
  <p>I need help in coding part how to do this using python or robot framework code.</p>
  
  <p>I need some example code</p>