Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
config:json [2012/09/28 10:24] – add a keyword bidou | 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 ====== | ||
+ | <WRAP center round tip 60%> | ||
+ | Starting with version 1.25, Geany has a built-in JSON filetype. | ||
+ | </ | ||
- | Although | + | JSON files are intended for serializing |
- | Add this to the '' | + | Add this to the '' |
<code ini> | <code ini> | ||
[Extensions] | [Extensions] | ||
Line 17: | Line 20: | ||
And create a new filedef named '' | And create a new filedef named '' | ||
- | <code ini> | + | <file properties filetypes.JSON.conf> |
[styling=C] | [styling=C] | ||
Line 24: | Line 27: | ||
[settings] | [settings] | ||
- | extension=json | ||
lexer_filetype=Javascript | lexer_filetype=Javascript | ||
- | comment_single=# | + | extension=json |
- | comment_use_indent=true | + | 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=1 | + | #type=1 |
- | </code> | + | </file> |
+ | |||
+ | === Build Commands === | ||
+ | |||
+ | For people using Unix, the following will be helpful for checking your JSON files for correctness. | ||
+ | |||
+ | <file bash / | ||
+ | #!/bin/sh | ||
+ | |||
+ | if which python >/ | ||
+ | python -m json.tool <" | ||
+ | | sed ' | ||
+ | elif which perl >/ | ||
+ | perl -MJSON -e 'local $/; | ||
+ | |sed ' | ||
+ | else | ||
+ | echo "No known JSON parsers found" >& | ||
+ | exit 1 | ||
+ | fi | ||
+ | </ | ||
+ | |||
+ | 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:// | ||
{{tag> | {{tag> | ||
+ | ~~NOTOC~~ | ||
+ |