public static void JsonToBion(string jsonPath, string bionPath, string toDictionaryPath = null)
        {
            using (WordCompressor compressor = (String.IsNullOrEmpty(toDictionaryPath) ? null : WordCompressor.OpenWrite(toDictionaryPath)))
            {
                string toPath = (compressor == null ? bionPath : Path.ChangeExtension(bionPath, ".preopt.bion"));

                using (JsonTextReader reader = new JsonTextReader(new StreamReader(jsonPath)))
                    using (BionWriter writer = new BionWriter(File.Create(toPath), compressor: compressor))
                    {
                        JsonToBion(reader, writer);
                    }

                if (compressor != null)
                {
                    string containerIndexPath = Path.ChangeExtension(bionPath, ".cdx");
                    string searchIndexPath    = Path.ChangeExtension(bionPath, ".idx");

                    using (BionReader reader = new BionReader(File.OpenRead(toPath), compressor: compressor))
                        using (BufferedWriter writer = new BufferedWriter(File.Create(bionPath)))
                        {
                            reader.RewriteOptimized(writer, containerIndexPath, searchIndexPath);
                        }

                    File.Delete(toPath);

                    // :/ Rewrite compressor; pre-optimize pass calls Dispose which writes it too early.
                    compressor.Write(File.OpenWrite(toDictionaryPath));
                }
            }
        }