You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**jsonfmt** is a powerful tool for handling JSON document.
10
10
11
-
It is similar to [jq](https://github.com/jqlang/jq), but simpler.
11
+
It is as powerful as [jq](https://github.com/jqlang/jq), but simpler.
12
+
12
13
13
14
## Features
14
15
@@ -20,7 +21,7 @@ It is similar to [jq](https://github.com/jqlang/jq), but simpler.
20
21
-[Show the overview of a large JSON.](#show-the-overview-of-a-large-json)
21
22
-[Copy the result to clipboard.](#copy-the-result-to-clipboard)
22
23
-[3. Minimize the JSON document.](#3-minimize-the-json-document)
23
-
-[4. Pick out parts of a large JSON via JSONPath.](#4-pick-out-parts-of-a-large-json-via-jsonpath)
24
+
-[4. Pick out parts of a large JSON via JmesPath.](#4-pick-out-parts-of-a-large-json-via-jmespath)
24
25
-[5. Convert formats between JSON, TOML and YAML.](#5-convert-formats-between-json-toml-and-yaml)
25
26
-[JSON to TOML and YAML](#json-to-toml-and-yaml)
26
27
-[TOML to JSON and YAML](#toml-to-json-and-yaml)
@@ -58,7 +59,7 @@ $ jsonfmt [options] [files ...]
58
59
-`-i {0-8,t}`: number of spaces for indentation (default: 2)
59
60
-`-o`: show data structure overview
60
61
-`-O`: overwrite the formated text to original file
61
-
-`-p JSONPATH`: output part of the object via jsonpath
62
+
-`-p JSONPATH`: output part of the object via jmespath
62
63
-`-s`: sort keys of objects on output
63
64
-`--set 'foo.k1=v1;k2[i]=v2'`: set the keys to values (seperated by `;`)
64
65
-`--pop 'k1;foo.k2;k3[i]'`: pop the specified keys (seperated by `;`)
@@ -213,13 +214,15 @@ $ echo '{
213
214
{"age":21,"items":["pen","phone"],"name":"alex"}
214
215
```
215
216
216
-
### 4. Pick out parts of a large JSON via JSONPath.
217
+
### 4. Pick out parts of a large JSON via JmesPath.
217
218
218
-
**JSONPath** is a way to query the sub-elements of a JSON document.
219
+
Unlike from jq's private solution, `jsonfmt` uses [JmesPath](https://jmespath.org/) as its query language.
219
220
220
-
It likes the XPath for xml, which can extract part of the content of a given JSON document through a simple syntax.
221
+
Among the many JSON query languages, `JmesPath` is the most popular one ([compared here](https://npmtrends.com/JSONPath-vs-jmespath-vs-jq-vs-json-path-vs-json-query-vs-jsonata-vs-jsonpath-vs-jsonpath-plus-vs-node-jq)).
222
+
It is more general than `jq`, and more intuitive and powerful than `JsonPath`.
### 5. Convert formats between JSON, TOML and YAML.
261
329
262
330
The *jsonfmt* can recognize any format of JSON, TOML and YAML from files or `stdin`. Either formats can be converted to the other by specifying the "-f" option.
0 commit comments