Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
config:json [2013/09/11 09:39] – replace "filetypes_extensions.conf" by "filetype_extensions.conf" (remove 's' from "filetype") cyrille37 | config:json [2015/04/08 23:38] (current) – Add a tip that Geany 1.25 has the filetype builtin colombanw | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== JSON Filetype ====== | ====== JSON Filetype ====== | ||
- | JSON files are intended for serializing data objects, but are sometimes used as configuration files. | + | <WRAP center round tip 60%> |
+ | Starting with version 1.25, Geany has a built-in JSON filetype. | ||
+ | </ | ||
+ | |||
+ | JSON files are intended for serializing data objects, but are sometimes used as configuration files. | ||
Add this to the '' | Add this to the '' | ||
Line 17: | Line 21: | ||
And create a new filedef named '' | And create a new filedef named '' | ||
<file properties filetypes.JSON.conf> | <file properties filetypes.JSON.conf> | ||
- | [styling] | + | [styling=C] |
- | default=default | + | |
- | number=number | + | |
- | string=string | + | |
- | word=word | + | |
- | identifier=identifier, | + | |
[keywords] | [keywords] | ||
Line 28: | Line 27: | ||
[settings] | [settings] | ||
- | lexer_filetype=YAML | + | lexer_filetype=Javascript |
extension=json | extension=json | ||
- | comment_single= | + | mime_type=application/ |
[indentation] | [indentation] | ||
- | width=2 | + | #width=4 |
# 0 is spaces, 1 is tabs, 2 is tab & spaces | # 0 is spaces, 1 is tabs, 2 is tab & spaces | ||
- | type=0 | + | #type=1 |
</ | </ | ||
Line 43: | Line 42: | ||
<file bash / | <file bash / | ||
- | #!/bin/bash | + | #!/bin/sh |
if which python >/ | if which python >/ | ||
- | python -m json.tool <$1 2>&1 >/ | + | python -m json.tool <"$1" |
- | | sed ' | + | | sed ' |
elif which perl >/ | elif which perl >/ | ||
- | perl -MJSON -e 'local $/; | + | perl -MJSON -e 'local $/; |
- | |sed ' | + | |sed ' |
else | else | ||
echo "No known JSON parsers found" >&2 | echo "No known JSON parsers found" >&2 | ||
Line 58: | Line 57: | ||
In Geany, go to the Build menu and 'Set Build Commands...' | In Geany, go to the Build menu and 'Set Build Commands...' | ||
+ | |||
+ | === Pretty Printing === | ||
+ | |||
+ | Assuming you have Python installed, pretty printing (aka formatting) of JSON is very easy with Geany: | ||
+ | |||
+ | * Python is required (works with Python 2 and 3) | ||
+ | * Configure Geany: Edit-> | ||
+ | * In the dialog add a new command and simply use: //python -mjson.tool// | ||
+ | |||
+ | To use this, select some string in Geany and use Edit-> | ||
+ | Alternatively, | ||
+ | For details, read the [[http:// | ||