I am using the latex beamer and trying to get the true value of the flag key in the JSON format red too but I am just getting it black as shown in the screen shot below. How can I get it red too?

enter image description here






% switch used as state variable


  showstringspaces    = false,
  keywords            = {false,true},
  alsoletter          = 0123456789.,
  morestring          = [s]{"}{"},
  stringstyle         = \ifcolonfoundonthisline\JSONstringvaluestyle\fi,
  MoreSelectCharTable =%
  basicstyle          = \ttfamily,
  keywordstyle        = \ttfamily\bfseries,

% flip the switch if a colon is found in Pmode

  %override by keyword style if a keyword is detected!

% reset the switch at the end of line

\author{Alex XYZ}
\institute{University XYZ}



\begin{frame}[fragile]{Service Provider - Request and Response}

  "mac": "10:B5:S3:06:C6:E9",
  "time":"12.09.2015 13:45:00",
  "flag": "true"


  • Thanks for the code. This is really useful. A hint for all others visiting this page trying to find JSON styling for Latex: if you replace the line 'stringstyle = \ifcolonfoundonthisline\JSONstringvaluestyle\fi,' with 'stringstyle = \color{blue}\ifcolonfoundonthisline\JSONstringvaluestyle\fi,' (replace blue by whatever color you prefer), you can also color the JSON keys. – Hubert Grzeskowiak May 13 '16 at 12:40

If you delete this line

  keywords            = {false,true},

the string "true" is treated as a string and goes red

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.