Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I beautify JSON inside a document?

I was writing a LaTeX document, using Lyx as a front-end. I did not find a way to correctly format JSON data inside these documents.

How can I beautify or format JSON data inside a Latex document?

like image 424
Legend Avatar asked Nov 22 '09 21:11

Legend


People also ask

How beautify JSON vs code?

Hit F1 or "cmd+shift+p" and type install and then type Prettify JSON and hit enter.


1 Answers

I'm using minted package.

First you have to install and configure it (do not forget to add pygmentize.cmd file on Windows 7). Then you have to add \usepackage{minted} to the LaTeX Preambel and finally insert following code into TeX Code box (for JSON you can use js code type):

\begin{listing}
\begin{minted}[frame=single,
               framesep=3mm,
               linenos=true,
               xleftmargin=21pt,
               tabsize=4]{js}
{     
    "firstName": "John"
    "lastName" : "Smith",
    "age" : 25
}
\end{minted}
\caption{JSON example} 
\label{json-example}
\end{listing}

It is not perfect solution, but it works and produce really nice listing: minted json example

like image 184
Lukasz R. Avatar answered Oct 21 '22 10:10

Lukasz R.