title: Why does c# utf8-json need to serialize obj to utf8 byte[] and then utf8.getstring?What are the benefits of doing this?
body: <p>Why does c# utf8-json need to serialize obj to utf8 byte[] and then utf8.getstring?What are the benefits of doing this?</p>
  
  <p>Utf8-json is one of the top speed JSON serialization tools in C #. When serializing json, the object is usually parsed into a string or char, then filled into StringBuilder, which maintains a char [], and finally calls the ToString () method to turn char [] into String. And utf8-json maintains a byte [], which first parses the objects into byte [] in utf8 format, and then calls UTF8. GetString () method on this byte []. I don't know the difference between this and other methods. Is it a performance difference? But through my verification, char [] -> ToString() becomes string faster than byte [] -> UTF8.GetString(). Why does utf8-json do this?</p>
  
  <p>obj -> char[] -> string </p>
  
  <p>obj -> byte[] -> string</p>
  
  <hr>
  
  <p>I think I'm express wrong. I mean why the same serialization logic, UTF-8 uses byte [] to store, stringbuiler uses char [] to store, and UTF-8 is faster.</p>
  
  <p>On. net fx, I spliced JSON into StringBuilder to compare performance with utf-8. The result is that UTF-8 is twice as fast. By reading the source code, I found that our serialization logic is the same, but why can UTF-8 be twice as fast as me? You know, UTF-8 also has a layer of byte [] to string consumption, and stringbuilder's ToString () is faster than UTF8. GetString ().</p>