"name" : "alan",
 "alias" : "nala"

If I use



How can I highlight JSON string values (on the right side) but not the attributes (left side)?


A MWE is really needed here, so what follows is a bit of a shot in the dark...

Edit: now you can specify a distinct style for numerical JSON values.

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



\section{A simple example}
 "name" : "alan",
 "alias" : "nala",

\section{A more complicated example}
  "firstName": "John",
  "lastName": "Smith",
  "isAlive": true,
  "age": 25,
  "height_cm": 167.6,
  "address": {
    "streetAddress": "21 2nd Street",
    "city": "New York",
    "state": "NY",
    "postalCode": "10021-3100"
  "phoneNumbers": [
      "type": "home",
      "number": "212 555-1234"
      "type": "office",
      "number": "646 555-4567"

| improve this answer | |
  • how about set another style number w/o quote? – keepscoding Aug 9 '14 at 15:28
  • @user3782003 See my edit. In the future, please post a minimal working example (MWE) in your question. – jub0bs Aug 9 '14 at 16:04
  • What about having escaped quotes on the right side? I have got this one: "content": "<Dat url=\"yawRate\"\\n ><Abs name=\"yawRate\" val=\"-.01\"/>\\n</Dat>" and want the whole string to be in one color as it is one value. Can you help? – tellob Jun 18 '15 at 6:52
  • Did with an additional morestring = [s]{"<}{>"} – tellob Jun 18 '15 at 7:08

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.