title: opening json string to easily read and write to in ruby
body: <p>I have a json file. I am using it to store information, and as such it is constantly going to be both read and written.</p>
  <p>I am completely new to ruby and oop in general, so I am sure I am going about this in a crazy way.</p>
  <pre><code>class Load
      def initialize(save_name)
      puts &quot;loading &quot; + save_name
          @data = JSON.parse(IO.read( $user_library + save_name ))
          @subject = @data[&quot;subject&quot;]
          @id = @data[&quot;id&quot;]
          @save_name = @data[&quot;save_name&quot;]
          @listA = @data[&quot;listA&quot;] # is an array containing dictionaries
          @listB = @data[&quot;listB&quot;] # is an array containing dictionaries
          
      end
      attr_reader :data, :subject, :id, :save_name, :listA, :listB
  end
   
  example = Load.new(&quot;test.json&quot;)
  puts example.id
  
  =&gt; 937489327389749
  </code></pre>
  <p>So I can now easily read the json file, but how could I write back to the file - refering to example? say I wanted to change the id <code>example.id.change(7129371289)</code>... or add dictionaries to lists A and B... Is this possible?</p>