Writes an object to a JSON file.

{\bfseries{Alias\+:}} {\ttfamily write\+JSON()}


\begin{DoxyItemize}
\item {\ttfamily file} {\ttfamily $<$String$>$}
\item {\ttfamily object} {\ttfamily $<$Object$>$}
\item {\ttfamily options} {\ttfamily $<$Object$>$}
\begin{DoxyItemize}
\item {\ttfamily spaces} {\ttfamily $<$Number$\vert$\+String$>$} Number of spaces to indent; or a string to use for indentation (i.\+e. pass `'\textbackslash{}t\textquotesingle{}{\ttfamily for tab indentation). See \mbox{[}the docs\mbox{]}(\href{https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify}{\texttt{ https\+://developer.\+mozilla.\+org/en-\/\+US/docs/\+Web/\+Java\+Script/\+Reference/\+Global\+\_\+\+Objects/\+JSON/stringify}}\#The\+\_\+space\+\_\+argument) for more info. -\/}EOL$<$\+String$>${\ttfamily Set EOL character. Default is}~\newline
{\ttfamily . -\/}replacer{\ttfamily \mbox{[}JSON replacer\mbox{]}(\href{https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify}{\texttt{ https\+://developer.\+mozilla.\+org/en-\/\+US/docs/\+Web/\+Java\+Script/\+Reference/\+Global\+\_\+\+Objects/\+JSON/stringify}}\#The\+\_\+replacer\+\_\+parameter)}
\item {\ttfamily Also accepts \mbox{[}}fs.\+write\+File$<$tt$>$options\mbox{]}(\href{https://nodejs.org/api/fs.html}{\texttt{ https\+://nodejs.\+org/api/fs.\+html}}\#fs\+\_\+fs\+\_\+writefile\+\_\+file\+\_\+data\+\_\+options\+\_\+callback) -\/callback$<$\+Function$>$\`{}
\end{DoxyItemize}
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_fs_extra_docs_writeJson_autotoc_md11046}{}\doxysection{Example\+:}\label{md_sfcode_node_modules_fs_extra_docs_writeJson_autotoc_md11046}

\begin{DoxyCode}{0}
\DoxyCodeLine{const fs = require('fs-\/extra')}
\DoxyCodeLine{}
\DoxyCodeLine{fs.writeJson('./package.json', \{name: 'fs-\/extra'\}, err => \{}
\DoxyCodeLine{  if (err) return console.error(err)}
\DoxyCodeLine{}
\DoxyCodeLine{  console.log('success!')}
\DoxyCodeLine{\})}
\DoxyCodeLine{}
\DoxyCodeLine{// With Promises}
\DoxyCodeLine{fs.writeJson('./package.json', \{name: 'fs-\/extra'\})}
\DoxyCodeLine{.then(() => \{}
\DoxyCodeLine{  console.log('success!')}
\DoxyCodeLine{\})}
\DoxyCodeLine{.catch(err => \{}
\DoxyCodeLine{  console.error(err)}
\DoxyCodeLine{\}) }

\end{DoxyCode}


\DoxyHorRuler{0}


{\bfseries{See also\+:}} \mbox{\hyperlink{md_sfcode_node_modules_fs_extra_docs_outputJson}{\`{}output\+Json()\`{}}} 