/// <summary>
        /// Write a Module to a JSON writer. If array is empty, don't write anything
        /// </summary>
        /// <param name="BinaryOutputDir"></param>
        /// <param name="TargetOutputDir"></param>
        /// <param name="Writer">Writer for the array data</param>
        /// <param name="Module"></param>
        private static void ExportModule(UEBuildModule Module, DirectoryReference BinaryOutputDir, DirectoryReference TargetOutputDir, JsonWriter Writer)
        {
            Writer.WriteValue("Name", Module.Name);
            Writer.WriteValue("Directory", Module.ModuleDirectory.FullName);
            Writer.WriteValue("Rules", Module.RulesFile.FullName);
            Writer.WriteValue("PCHUsage", Module.Rules.PCHUsage.ToString());

            if (Module.Rules.PrivatePCHHeaderFile != null)
            {
                Writer.WriteValue("PrivatePCH", FileReference.Combine(Module.ModuleDirectory, Module.Rules.PrivatePCHHeaderFile).FullName);
            }

            if (Module.Rules.SharedPCHHeaderFile != null)
            {
                Writer.WriteValue("SharedPCH", FileReference.Combine(Module.ModuleDirectory, Module.Rules.SharedPCHHeaderFile).FullName);
            }

            ExportJsonModuleArray(Writer, "PublicDependencyModules", Module.PublicDependencyModules);
            ExportJsonModuleArray(Writer, "PublicIncludePathModules", Module.PublicIncludePathModules);
            ExportJsonModuleArray(Writer, "PrivateDependencyModules", Module.PrivateDependencyModules);
            ExportJsonModuleArray(Writer, "PrivateIncludePathModules", Module.PrivateIncludePathModules);
            ExportJsonModuleArray(Writer, "DynamicallyLoadedModules", Module.DynamicallyLoadedModules);

            ExportJsonStringArray(Writer, "PublicSystemIncludePaths", Module.PublicSystemIncludePaths.Select(x => x.FullName));
            ExportJsonStringArray(Writer, "PublicIncludePaths", Module.PublicIncludePaths.Select(x => x.FullName));

            ExportJsonStringArray(Writer, "LegacyPublicIncludePaths", Module.LegacyPublicIncludePaths.Select(x => x.FullName));

            ExportJsonStringArray(Writer, "PrivateIncludePaths", Module.PrivateIncludePaths.Select(x => x.FullName));
            ExportJsonStringArray(Writer, "PublicLibraryPaths", Module.PublicSystemLibraryPaths.Select(x => x.FullName));
            ExportJsonStringArray(Writer, "PublicAdditionalLibraries", Module.PublicSystemLibraries.Concat(Module.PublicAdditionalLibraries));
            ExportJsonStringArray(Writer, "PublicFrameworks", Module.PublicFrameworks);
            ExportJsonStringArray(Writer, "PublicWeakFrameworks", Module.PublicWeakFrameworks);
            ExportJsonStringArray(Writer, "PublicDelayLoadDLLs", Module.PublicDelayLoadDLLs);
            ExportJsonStringArray(Writer, "PublicDefinitions", Module.PublicDefinitions);
            ExportJsonStringArray(Writer, "PrivateDefinitions", Module.Rules.PrivateDefinitions);
            ExportJsonStringArray(Writer, "ProjectDefinitions", /* TODO: Add method ShouldAddProjectDefinitions */ !Module.Rules.bTreatAsEngineModule ? Module.Rules.Target.ProjectDefinitions : new string[0]);
            ExportJsonStringArray(Writer, "ApiDefinitions", Module.GetEmptyApiMacros());
            Writer.WriteValue("ShouldAddLegacyPublicIncludePaths", Module.Rules.bLegacyPublicIncludePaths);

            if (Module.Rules.CircularlyReferencedDependentModules.Any())
            {
                Writer.WriteArrayStart("CircularlyReferencedModules");
                foreach (string ModuleName in Module.Rules.CircularlyReferencedDependentModules)
                {
                    Writer.WriteValue(ModuleName);
                }
                Writer.WriteArrayEnd();
            }

            if (Module.Rules.RuntimeDependencies.Inner.Any())
            {
                // We don't use info from RuntimeDependencies for code analyzes (at the moment)
                // So we're OK with skipping some values if they are not presented
                Writer.WriteArrayStart("RuntimeDependencies");
                foreach (ModuleRules.RuntimeDependency RuntimeDependency in Module.Rules.RuntimeDependencies.Inner)
                {
                    Writer.WriteObjectStart();

                    try
                    {
                        Writer.WriteValue("Path",
                                          Module.ExpandPathVariables(RuntimeDependency.Path, BinaryOutputDir, TargetOutputDir));
                    }
                    catch (BuildException buildException)
                    {
                        Log.TraceVerbose("Value {0} for module {1} will not be stored. Reason: {2}", "Path", Module.Name, buildException);
                    }

                    if (RuntimeDependency.SourcePath != null)
                    {
                        try
                        {
                            Writer.WriteValue("SourcePath",
                                              Module.ExpandPathVariables(RuntimeDependency.SourcePath, BinaryOutputDir,
                                                                         TargetOutputDir));
                        }
                        catch (BuildException buildException)
                        {
                            Log.TraceVerbose("Value {0} for module {1} will not be stored. Reason: {2}", "SourcePath", Module.Name, buildException);
                        }
                    }

                    Writer.WriteValue("Type", RuntimeDependency.Type.ToString());

                    Writer.WriteObjectEnd();
                }
                Writer.WriteArrayEnd();
            }
        }