CTAGS-JSON-OUTPUT(5)

πŸ“¦
version 6.2.1 Β· 5 versions
, in alpine 3.24, fedora 43, fedora 44

πŸ’– ctags-json-output β€” the manual page (section 5) πŸ’–

okay bestie, so this is ctags-json-output from Universal Ctags, and it's literally the page that explains how to get your tags as JSON. it's giving structured-data slay. πŸ¦‹


✨ SYNOPSIS ✨

ctags --output-format=json ...

🌸 DESCRIPTION 🌸

Universal Ctags supports JSON (<https://www.json.org/>) output β€” and strictly speaking it's JSON Lines (<https://jsonlines.org/>) β€” but only if your ctags executable was built with libjansson. no libjansson, no JSON, no cap. πŸ’…

By default, the JSON output goes to standard output. iconic behavior honestly.


πŸŽ€ FORMAT πŸŽ€

Each JSON line = one tag. one line, one tag, that's the whole vibe.

$ ctags --extras=+p --output-format=json --fields=-s input.py
{"_type": "ptag", "name": "JSON_OUTPUT_VERSION", "path": "1.0", "pattern": "in development"}
{"_type": "ptag", "name": "TAG_FILE_SORTED", "path": "1", "pattern": "0=unsorted, 1=sorted, 2=foldcase"}
...
{"_type": "tag", "name": "Klass", "path": "/tmp/input.py", "pattern": "/^class Klass:$/", "language": "Python", "kind": "class"}
{"_type": "tag", "name": "method", "path": "/tmp/input.py", "pattern": "/^    def method(self):$/", "language": "Python", "kind": "member", "scope": "Klass", "scopeKind": "class"}
...

So here's the tea β˜• β€” if a key does not start with _, it maps to a field of ctags. wanna see the whole list of fields? run the --output-format=json --list-fields options and it'll show you everything.

A key that does start with _ is meta info about that JSON line. Right now only the _type key is used:

  • if its value is tag, the JSON line is a regular tag
  • if its value is ptag, the line is a pseudo-tag

The output format can change in the future, so the JSON_OUTPUT_VERSION pseudo-tag exists to let client-tools handle those changes. current version is "1.0", and a client-tool can pull the version out with the path key from that pseudo-tag. πŸ‘‘

The JSON output format is newly designed and has no limitation found in the default tags file format. periodt.

  • The values for kind key are represented in long-name flags. No one-letter is here.
  • Scope names and scope kinds have distinguished keys: scope and scopeKind. They are combined in the default tags file format.

πŸ’œ DATA TYPE USED IN A FIELD πŸ’œ

Values for the most of all keys are represented in JSON string type. However, some of them are represented in string, integer, and/or boolean type. so like, don't assume everything's a string bestie. πŸ™ˆ

The --output-format=json --list-fields options show what kind of data type is used in a field of JSON.

$ ctags --output-format=json --list-fields
#LETTER NAME           ENABLED LANGUAGE         JSTYPE FIXED DESCRIPTION
F       input          yes     NONE             s--    no    input file
...
P       pattern        yes     NONE             s-b    no    pattern
...
f       file           yes     NONE             --b    no    File-restricted scoping
...
e       end            no      NONE             -i-    no    end lines of various items
...

The JSTYPE column shows the data types:

  • 's' β€” string
  • 'i' β€” integer
  • 'b' β€” boolean (true or false)

for an example, the value for pattern field of ctags takes a string or a boolean value. both? yes. it's flexible like that. ✨


🌈 VERSIONS 🌈

🧚 Change since "0.0"

  • New key kindName for TAG_ROLE_DESCRIPTION pseudo tag

kindName is added to store the name of the kind in TAG_ROLE_DESCRIPTION pseudo tags.

In 0.0, a "TAG_ROLE_DESCRIPTION" pseudo tag was printed like:

{"_type": "ptag", "name": "TAG_ROLE_DESCRIPTION",
                  "parserName": "LANG!KIND", }

In 1.0, it is printed like:

{"_type": "ptag", "name": "TAG_ROLE_DESCRIPTION",
                  "parserName": "LANG",
                  "kindName": "KIND",  }

look at that glow-up fr fr πŸ’–


⭐ SEE ALSO ⭐


go read those too bestie, iykyk πŸ“š

okay that's the whole page!! this was Universal Ctags, version 1.0, and the date on this bad boy is part of the CTAGS-JSON-OUTPUT(5) footer lineup β€” slay, you're all caught up. bye pookie πŸ«ΆπŸ’…βœ¨

πŸ“¦ where this page comes from