コード例 #1
0
        private static void WriteJsonDocument(IArchiveEntry entry, object value)
        {
            using var zipStream = entry.OpenWrite();
            using var sr        = new StreamWriter(zipStream);
            using var writer    = new JsonTextWriter(sr);

            var serializer = new JsonSerializer();

            serializer.Serialize(writer, value);
        }
コード例 #2
0
        public override void BuildResource(IResource resource, IArchiveEntry contentEntry)
        {
            var serializer = new JsonSerializer()
            {
                Formatting = Formatting.None
            };

            JObject document;

            using (var sr = new StreamReader(resource.Content.LoadStream()))
                using (var reader = new JsonTextReader(sr))
                {
                    document = serializer.Deserialize <JObject>(reader);
                }

            using var zipStream    = contentEntry.OpenWrite();
            using var streamWriter = new StreamWriter(zipStream);
            serializer.Serialize(streamWriter, document);
        }