async Task <string> GetJsonFromThrift(byte[] bytes) { try { var _memoryBufferTransport = new TMemoryBufferTransport(bytes, new TConfiguration()); var _thrift = new TCompactProtocol(_memoryBufferTransport); while (true) { var field = await _thrift.ReadFieldBeginAsync(CancellationToken.None); if (field.Type == TType.Stop) { break; } if (field.Type == TType.String) { var str = await _thrift.ReadStringAsync(CancellationToken.None); if (!string.IsNullOrEmpty(str)) { if (str.StartsWith("{") && str.EndsWith("}")) { return(str); } } } await _thrift.ReadFieldEndAsync(CancellationToken.None); } } catch { } var json = Encoding.UTF8.GetString(bytes); try { if (json.Contains("{") && json.Contains("}")) { var str = json.Substring(json.IndexOf("{")); str = str.Substring(0, str.LastIndexOf("}") + 1); return(str); } } catch { } return(json); }