name: JSON fileTypes:

scopeName: source.json repository:

number: 
  name: constant.numeric.json
  match: |-
    (?x:         # turn on extended mode
                     -?         # an optional minus
                     (?:
                       0        # a zero
                       |        # ...or...
                       [1-9]    # a 1-9 character
                       \d*      # followed by zero or more digits
                     )
                     (?:
                       \.       # a period
                       \d+      # followed by one or more digits
                       (?:
                         [eE]   # an e character
                         [+-]?  # followed by an option +/-
                         \d+    # followed by one or more digits
                       )?       # make exponent optional
                     )?         # make decimal portion optional
                   )
  comment: handles integer and decimal numbers
constant: 
  name: constant.language.json
  match: \b(?:true|false|null)\b
value: 
  patterns: 
  - include: "#constant"
  - include: "#number"
  - include: "#string"
  - include: "#array"
  - include: "#object"
  comment: the 'value' diagram at http://json.org
array: 
  name: meta.structure.array.json
  endCaptures: 
    "0": 
      name: punctuation.definition.array.end.json
  begin: \[
  beginCaptures: 
    "0": 
      name: punctuation.definition.array.begin.json
  end: \]
  patterns: 
  - include: "#value"
  - name: punctuation.separator.array.json
    match: ","
  - name: invalid.illegal.expected-array-separator.json
    match: "[^\\s\\]]"
object: 
  name: meta.structure.dictionary.json
  endCaptures: 
    "0": 
      name: punctuation.definition.dictionary.end.json
  begin: \{
  beginCaptures: 
    "0": 
      name: punctuation.definition.dictionary.begin.json
  end: \}
  patterns: 
  - include: "#string"
    comment: the JSON object key
  - name: meta.structure.dictionary.value.json
    endCaptures: 
      "1": 
        name: punctuation.separator.dictionary.pair.json
    begin: ":"
    beginCaptures: 
      "0": 
        name: punctuation.separator.dictionary.key-value.json
    end: (,)|(?=\})
    patterns: 
    - include: "#value"
      comment: the JSON object value
    - name: invalid.illegal.expected-dictionary-separator.json
      match: "[^\\s,]"
  - name: invalid.illegal.expected-dictionary-separator.json
    match: "[^\\s\\}]"
  comment: a JSON object
string: 
  name: string.quoted.double.json
  endCaptures: 
    "0": 
      name: punctuation.definition.string.end.json
  begin: "\""
  beginCaptures: 
    "0": 
      name: punctuation.definition.string.begin.json
  end: "\""
  patterns: 
  - name: constant.character.escape.json
    match: |-
      (?x:                # turn on extended mode
                           \\                # a literal backslash
                           (?:               # ...followed by...
                             ["\\/bfnrt]     # one of these characters
                             |               # ...or...
                             u               # a u
                             [0-9a-fA-F]{4}  # and four hex digits
                           )
                         )
  - name: invalid.illegal.unrecognized-string-escape.json
    match: \\.

uuid: 0C3868E4-F96B-4E55-B204-1DCB5A20748B foldingStartMarker: |-

(?x:       # turn on extended mode
                          ^        # a line beginning with
                          \s*      # some optional space
                          [{\[]    # the start of an object or array
                          (?!      # but not followed by
                            .*     # whatever
                            [}\]]  # and the close of an object or array
                            ,?     # an optional comma
                            \s*    # some optional space
                            $      # at the end of the line
                          )
                          |        # ...or...
                          [{\[]    # the start of an object or array
                          \s*      # some optional space
                          $        # at the end of the line
                        )

patterns:

foldingStopMarker: |-

(?x:     # turn on extended mode
                         ^      # a line beginning with
                         \s*    # some optional space
                         [}\]]  # and the close of an object or array
                       )

keyEquivalent: ^~J