title: ruby write json file from an object
body: <p>I'm getting an error <code>expected ':' after property name in object at line 1 column 15</code> how can I get rid of '=>'? when I replace "=>" by ":" in the to_json methods I'm getting an error <code>syntax error, unexpected ':', expecting =&gt;</code></p>
  
  <pre><code>require 'json'    
  class Province
          attr_accessor :provOrigine, :destination, :total, 
                          :q1, :q2, :q3, :q4
  
          def initialize(line)
              @provOrigine =  line.split(';').first.split(",").first
              @destination =  line.split(';').at(1).split(',').first
              @q1 = (line.split(';').at(4)).to_i
              @q2 = (line.split(';').at(5)).to_i
              @q3 = (line.split(';').at(6)).to_i
              @q4 = (line.split(';').at(7)).to_i
          end
          def to_json
            {'provOrigine' =&gt; @provOrigine.to_s, 'destination' =&gt; @destination.to_s, 'q1' =&gt; @q1.to_s, 'q2' =&gt; @q2.to_s, 'q3' =&gt; @q3.to_s, 'q4' =&gt; @q4.to_s}
          end
  
  
      end
  </code></pre>
  
  <p>...
  <code>prov_instances =</code> contains All the instances of Province
  ...</p>
  
  <pre><code>File.open("file_json_complete.json", "w") do |f|
    prov_instances.each do |n|
      f.write(n.to_json)
    end
  end
  </code></pre>
  
  <p>this is the result I'm getting</p>
  
  <pre><code>    {"provOrigine"=&gt;"Alberta", "destination"=&gt;"Terre-Neuve-et-Labrador", "q1"=&gt;"777", "q2"=&gt;"1089", "q3"=&gt;"553", "q4"=&gt;"474"}{"provOrigine"=&gt;"Alberta", "destination"=&gt;"Nunavut", "q1"=&gt;"24", "q2"=&gt;"70", "q3"=&gt;"29", "q4"=&gt;"29"}{"provOrigine"=&gt;"Alberta", "destination"=&gt;"Île-du-Prince-Édouard", "q1"=&gt;"116", "q2"=&gt;"69", "q3"=&gt;"150", "q4"=&gt;"64" 
  }
  </code></pre>
  
  <p>and there is no commas between each object?</p>