title: How to parse JSON in Java using a high performance parser?
body: <p>My input is an array with approx. 2,000 elements received every second, sometimes several times per second. Every element of the array has 3 Big Decimals.</p>
  
  <p>Jackson (com.fasterxml) is the slowest part of otherwise sub-millisecond app and takes 15 milliseconds (avg). The slow function is objectMapper.readValue(text, MyDto.class);</p>
  
  <p>When using a custom JSON parsing algorithm based on substring, it takes microseconds. With ObjectMapper it's 15 milliseconds.</p>
  
  <p>Parsing JSON via substring is a bad practice because the code is verbose and prone to bugs. </p>
  
  <p>What would you use for JSON parsing? The requirement is a very fast algorithm.</p>
  
  <p><a href="https://github.com/ngs-doo/dsl-json" rel="nofollow noreferrer">https://github.com/ngs-doo/dsl-json</a> I found DSL json, but don't know hot to make it parse a String with JSON into my DTO. I haven't found a simple fast algorithm to parse JSON from String into a DTO.</p>
  
  <p>EDIT: The input to be parsed is at:</p>
  
  <pre><code>https://pastebin.com/831YtBdq
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>public class BitstampOrderBook {
      private long timestamp;
      private List&lt;List&lt;BigDecimal&gt;&gt; bids;
      private List&lt;List&lt;BigDecimal&gt;&gt; asks;
  
      public BitstampOrderBook() {
  
      }
  
      public BitstampOrderBook(long timestamp, List&lt;List&lt;BigDecimal&gt;&gt; bids, List&lt;List&lt;BigDecimal&gt;&gt; asks) {
          this.timestamp = timestamp;
          this.bids = bids;
          this.asks = asks;
      }
  
      public long getTimestamp() {
          return timestamp;
      }
  
      public List&lt;List&lt;BigDecimal&gt;&gt; getBids() {
          return bids;
      }
  
      public List&lt;List&lt;BigDecimal&gt;&gt; getAsks() {
          return asks;
      }
  }
  
  public class BitstampOrder {
      private BigDecimal price;
  
      private BigDecimal amount;
  
      private String datetime;
  
      private int id;
  
      @SerializedName("order_type")
      private int orderType;
  
      public BigDecimal getPrice() {
          return price;
      }
  
      public void setPrice(BigDecimal price) {
          this.price = price;
      }
  
      public BigDecimal getAmount() {
          return amount;
      }
  
      public void setAmount(BigDecimal amount) {
          this.amount = amount;
      }
  
      public String getDatetime() {
          return datetime;
      }
  
      public void setDatetime(String datetime) {
          this.datetime = datetime;
      }
  
      public int getId() {
          return id;
      }
  
      public void setId(int id) {
          this.id = id;
      }
  
      public int getOrderType() {
          return orderType;
      }
  
      public void setOrderType(int orderType) {
          this.orderType = orderType;
      }
  
      @Override
      public String toString() {
          return "BitStampOrder{" +
                  "price=" + price +
                  ", amount=" + amount +
                  ", datetime='" + datetime + '\'' +
                  ", id='" + id + '\'' +
                  ", orderType='" + orderType + '\'' +
                  '}';
      }
  }
  </code></pre>
  
  <p>Main:</p>
  
  <pre><code>BitstampOrderBook orderBook = objectMapper.readValue(jsonString, BitstampOrderBook.class);
  </code></pre>
  
  <p>JProfiler (Jackson):</p>
  
  <pre><code>https://i.imgur.com/mjdbDQe.png
  </code></pre>
  
  <p>EDIT 2: </p>
  
  <p>JProfiler (Gson):</p>
  
  <pre><code>https://i.imgur.com/WcHVhhd.png
  </code></pre>
  
  <p>As can be seen from JProfiler, Gson is several times faster than Jackson. What would be even faster than Gson?</p>