示例#1
0
        public static string AsJson(this PackedObject obj)
        {
            if (obj.UseCompression)
            {
                var stream = new MemoryStream(obj.ObjectData);
                using (var zInStream = new GZipInputStream(stream))
                {
                    var stream2 = new MemoryStream();
                    zInStream.CopyTo(stream2);

                    var json = Encoding.UTF8.GetString(stream2.ToArray());

                    return(JToken.Parse(json).ToString(Formatting.Indented));
                }
            }

            {
                var json = Encoding.UTF8.GetString(obj.ObjectData);

                return(JToken.Parse(json).ToString(Formatting.Indented));
            }
        }