title: parsing to json using jackson-mapper causes
body: <p>I have a big object I want to parse to json <code>Jackson-mapper</code>.
  It works fine, till the object becomes too big.</p>
  
  <p>I'm using intellij on mac.</p>
  
  <p>code:</p>
  
  <pre><code>private String serializeToJson(T item) {
      String json;
      ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
      try {
          json = ow.writeValueAsString(item);
      } catch (IOException e) {
          e.printStackTrace();
          json = "";
      }
      return json;
  }
  </code></pre>
  
  <p>error:</p>
  
  <pre><code>Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
  :BL_generate FAILED
  
  BUILD FAILED
  
  Total time: 12 mins 14.491 secs
      at java.util.Arrays.copyOfRange(Arrays.java:3664)
      at java.lang.String.&lt;init&gt;(String.java:201)
      at java.lang.StringBuilder.toString(StringBuilder.java:407)
      at org.codehaus.jackson.util.TextBuffer.contentsAsString(TextBuffer.java:362)
      at org.codehaus.jackson.io.SegmentedStringWriter.getAndClear(SegmentedStringWriter.java:100)
      at org.codehaus.jackson.map.ObjectWriter.writeValueAsString(ObjectWriter.java:394)
      at com.waze.routing.automation.io.string.JsonFileHandler.serializeToJson(JsonFileHandler.java:81)
  
  I'm not sure how to split an object or to write it in parts (append to existing file)
  </code></pre>
  
  <p>i have tried to enlarge heap space, but it didn't help</p>
  
  <pre><code>task BL_generate(type: JavaExec) {
      jvmArgs = ["-Xms1024m","-Xmx1024m"]
      classpath sourceSets.main.runtimeClasspath
      main = "com.m.BaselineGeneratorRunner"
  }
  </code></pre>
  
  <p>i have read few posts: <a href="https://stackoverflow.com/questions/15097939/working-with-extra-large-json-files-return-always-out-of-memory">post1</a>, <a href="https://stackoverflow.com/questions/9799549/java-android-java-lang-outofmemoryerror-while-building-a-json-object">post2</a></p>
  
  <p>but i'm not sure how to use it in my case. How can streaming help me with one big object? (not array).</p>