Skip to content

Instantly share code, notes, and snippets.

@atomicptr
Created September 14, 2016 15:03
Show Gist options
  • Save atomicptr/484276c6d637be157213237d48181050 to your computer and use it in GitHub Desktop.
Save atomicptr/484276c6d637be157213237d48181050 to your computer and use it in GitHub Desktop.
C# implementation of the Potato format https://github.com/atomicptr/potato
/*
Copyright (C) 2016 Christopher Kaster
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
*/
using System;
using System.Text;
using System.IO;
using System.IO.Compression;
using Newtonsoft.Json;
using Newtonsoft.Json.Bson;
namespace PotatoSharp {
public static class PotatoParser {
public static dynamic Parse(byte[] bytes) {
using(Stream inputStream = new MemoryStream(bytes))
using(var gzipStream = new GZipStream(inputStream, CompressionMode.Decompress))
using (BsonReader reader = new BsonReader(gzipStream)) {
var serializer = JsonSerializer.CreateDefault();
return serializer.Deserialize<dynamic>(reader);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment