title: Java parsing large json
body: <p>I want to parse json file from OSM servers. It may vary from few Kbs to 10-20 Mbs. I'm using GSON right now but I'm facing some performance issues when parsing large file (like 10 Mbs). It takes about 10 seconds only for parsing in streaming mode:</p>
  
  <pre><code>JsonReader reader = new JsonReader(new StringReader(data));
      try {
          reader.beginObject();
          while(reader.hasNext()){
              String name = reader.nextName();
              if(name.equals("elements")){
                  reader.beginArray();
                  while(reader.hasNext()){
                      String type = null;
                      Long id = 0L;
                      Double lat = 0D;
                      Double lon = 0D;
                      ArrayList&lt;Long&gt; nodes = new ArrayList&lt;&gt;();
                      Tags tags = null;
                      reader.beginObject();
                      while(reader.hasNext()) {
                          name = reader.nextName();
                          switch (name) {
                              case "type":
                                  type = reader.nextString();
                                  break;
                              case "tags":
                                  reader.beginObject();
                                  while (reader.hasNext()) {
                                      name = reader.nextName();
                                      if (name.equals("highway"))
                                          tags = new Tags(reader.nextString());
                                      else
                                          reader.skipValue();
                                  }
                                  reader.endObject();
                                  break;
                              default:
                                  reader.skipValue();
                                  break;
                          }
                      }
                      reader.endObject();
                  }
                  reader.endArray();
              }
              else{
                  reader.skipValue();
              }
          }
          reader.endObject();
          reader.close();
      } catch (IOException e) {
          e.printStackTrace();
      }
  </code></pre>
  
  <p>For now it is an bottleneck for my application. I have tried already some other libraries but there wasn't any improvement. Is there anything I'm doing wrong or is there some special way to parse large json data?</p>