diff --git a/PrettyJson.py b/PrettyJson.py index c3561ec..d7d2ae5 100644 --- a/PrettyJson.py +++ b/PrettyJson.py @@ -50,10 +50,9 @@ class PrettyJsonBaseCommand: bracket_newline = re.compile(r'^((\s*)".*?":)\s*([\[])', re.MULTILINE) @staticmethod - def json_loads(selection: str, object_pairs_hook=None) -> dict: - hook = OrderedDict if object_pairs_hook is None else object_pairs_hook + def json_loads(selection: str, object_pairs_hook=OrderedDict) -> dict: return json.loads( - selection, object_pairs_hook=hook, parse_float=decimal.Decimal + selection, object_pairs_hook=object_pairs_hook, parse_float=decimal.Decimal ) @staticmethod diff --git a/README.md b/README.md index 60f5b62..6336667 100644 --- a/README.md +++ b/README.md @@ -4,18 +4,27 @@ Prettify/Minify/Query/Goto/Validate/Lint JSON plugin for Sublime Text 3 & 4 ## Installation +### Package Control (Recommended) + Install this sublime text 3/4 package via [Package Control][] search for package: "[**Pretty JSON**][]" -### or manually install +### Manual Installation -- `cd ` - (for example on Mac it is - `~/Library/Application\ Support/Sublime\ Text\ 3/Packages` - or - `~/Library Application\ Support/Sublime\ Text/Packages`) +**Sublime Text 4** + +- `cd ` (for example on Mac it is `~/Library/Application\ Support/Sublime\ Text\ 2/Packages` or `~/Library/Application\ Support/Sublime\ Text\ 3/Packages`) - `git clone https://github.com/dzhibas/SublimePrettyJson.git "Pretty JSON"` +**Sublime Text 3** + +- `cd ` (for example on Mac it is `~/Library/Application\ Support/Sublime\ Text\ 2/Packages` or `~/Library/Application\ Support/Sublime\ Text\ 3/Packages`) +- `git clone https://github.com/dzhibas/SublimePrettyJson.git "Pretty JSON"` +- `git checkout st3` + +**Sublime Text 2** +No longer supported + ## Usage To prettify JSON, make selection of json @@ -26,7 +35,7 @@ To prettify JSON, make selection of json - OS X: cmd+ctrl+j or through Command Palette Ctrl+Shift+P -find "Pretty JSON: Format (Pretty Print) JSON" +find "Pretty JSON: Format JSON" (you can search for part of it like 'pretty format') If selection is empty and configuration entry @@ -46,7 +55,7 @@ In case of found errors view will jump to error and will highlight it ### Compress / Minify JSON Using Command Palette Ctrl+Shift+P -find "Pretty JSON: Minify (compress) JSON" +find "Pretty JSON: Minify JSON" (you can search for part of it like 'json minify') this will make selection or full buffer as single line JSON which later you can use in command lines (curl/httpie) or somewhere else... @@ -62,7 +71,7 @@ you can add a setting like this to your .sublime-keymap file ### Convert JSON to XML Using Command Palette Ctrl+Shift+P search for -"Pretty JSON: JSON 2 XML" (you can search for part of it like '2XML') +"Pretty JSON: json2xml" (you can search for part of it like '2XML') this will convert your selected JSON of full buffer to XML and replace syntax and buffer to XML output