Thrift.Protocol.TJSONProtocol.WriteJSONString C# (CSharp) Method

WriteJSONString() private method

Write the bytes in array buf as a JSON characters, escaping as needed
private WriteJSONString ( byte b ) : void
b byte
return void
        private void WriteJSONString(byte[] b)
        {
            context.Write();
            trans.Write(QUOTE);
            int len = b.Length;
            for (int i = 0; i < len; i++)
            {
                if ((b[i] & 0x00FF) >= 0x30)
                {
                    if (b[i] == BACKSLASH[0])
                    {
                        trans.Write(BACKSLASH);
                        trans.Write(BACKSLASH);
                    }
                    else
                    {
                        trans.Write(b, i, 1);
                    }
                }
                else
                {
                    tempBuffer[0] = JSON_CHAR_TABLE[b[i]];
                    if (tempBuffer[0] == 1)
                    {
                        trans.Write(b, i, 1);
                    }
                    else if (tempBuffer[0] > 1)
                    {
                        trans.Write(BACKSLASH);
                        trans.Write(tempBuffer, 0, 1);
                    }
                    else
                    {
                        trans.Write(ESCSEQ);
                        tempBuffer[0] = HexChar((byte)(b[i] >> 4));
                        tempBuffer[1] = HexChar(b[i]);
                        trans.Write(tempBuffer, 0, 2);
                    }
                }
            }
            trans.Write(QUOTE);
        }