Skip to content

Commit 227cb17

Browse files
committed
- [#] update README
1 parent 61ae0ea commit 227cb17

File tree

3 files changed

+235
-148
lines changed

3 files changed

+235
-148
lines changed

README.e.md

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,32 @@ The `jsonfiddle` makes it easy to look at the JSON data from different aspects.
1616
- **`jsonfiddle esc`** will escape any arbitrary string so as to embed it as content of json string.
1717
- **`jsonfiddle fmt`** will format the JSON data, either compact it or pretty printing it. The order of fields are intact.
1818
- **`jsonfiddle sort`** will sort the JSON data fields recursively, so that the attributes at any level are in sorted order.
19+
- **`jsonfiddle x2j`** means xml to json. It will convert data from xml format into json.
1920
- **`jsonfiddle j2s`** means json to struct. It will extract the structure of JSON data as Go struct.
2021

2122
# Usage
2223

23-
### $ {{exec "jsonfiddle" | color "sh"}}
24+
```
25+
$ {{shell "jsonfiddle -V"}}
26+
```
27+
28+
### $ {{shell "jsonfiddle || true" | color "sh"}}
2429

25-
### $ {{shell "jsonfiddle esc" | color "sh"}}
30+
### $ {{shell "jsonfiddle esc || true" | color "sh"}}
2631

27-
### $ {{shell "jsonfiddle fmt" | color "sh"}}
32+
### $ {{shell "jsonfiddle fmt || true" | color "sh"}}
2833

29-
### $ {{shell "jsonfiddle sort" | color "sh"}}
34+
### $ {{shell "jsonfiddle sort || true" | color "sh"}}
3035

31-
### $ {{shell "jsonfiddle j2s" | color "sh"}}
36+
### $ {{shell "jsonfiddle j2s || true" | color "sh"}}
37+
38+
### $ {{shell "jsonfiddle x2j || true" | color "sh"}}
3239

3340
# Examples
3441

3542
## Escape with `jsonfiddle esc`
3643

37-
### $ {{shell "jsonfiddle esc -i test/Customer.ref" | color "json"}}
44+
### $ {{shell "jsonfiddle esc -i test/Customer.ref 2>/dev/null" | color "json"}}
3845

3946
### Usage
4047

@@ -72,7 +79,8 @@ There are times that json data may contain templates, i.e., strings like `{{"{{V
7279
}
7380
```
7481

75-
What's worse is that when such template variables are for `int`, e.g.: `"age":{{"{{Var_Age}}"}}`, they then wouldn't be able to handle it.
82+
What's worse is that when such template variables are for `int`, e.g.: `"age":{{"{{Var_Age}}"}}`, they then wouldn't be able to handle it, for inputs like
83+
{{cat "test/CustomerP.json" | color "sh"}}
7684

7785
To make such template variables work for those tools, the `-p,--protect` option is introduced:
7886

@@ -84,27 +92,33 @@ To make such template variables work for those tools, the `-p,--protect` option
8492

8593
$ jsonfiddle fmt -c -i test/Customer.json
8694

87-
#### > {{cat "test/Customer.ref" | color "json"}}
95+
#### > {{cat "test/CustomerC.ref" | color "json"}}
8896

8997
You can also do,
9098

91-
$ cat Customer.json | jsonfiddle fmt -c -i
99+
$ cat Customer.json | jsonfiddle fmt -c -i -
92100

93101
and the result is the same (and for all other examples using `-i` as well).
94102

95103
## Sort fields with `jsonfiddle sort`
96104

105+
### Sort in compact
106+
107+
$ jsonfiddle sort -c -i test/Customer.json
108+
109+
#### > {{cat "test/CustomerSC.ref" | color "json"}}
110+
97111
### Sort with pretty print
98112

99113
$ jsonfiddle sort -i test/Customer.json
100114

101115
#### > {{cat "test/CustomerSI.ref" | color "json"}}
102116

103-
### Sort in compact
104-
105-
$ jsonfiddle sort -c -i test/Customer.json
117+
### XML to JSON, sort then pretty print
106118

107-
#### > {{cat "test/CustomerSC.ref" | color "json"}}
119+
```
120+
$ {{shell "jsonfiddle x2j -i test/Books.xml | jsonfiddle sort -i - | jsonfiddle fmt -i -"}}
121+
```
108122

109123
## JSON to struct via `jsonfiddle j2s`
110124

@@ -127,7 +141,7 @@ Thus all the JSON comparison tools I found are failing under such hash request.
127141
- The latest binary executables are available under
128142
https://github.com/go-jsonfile/{{.Name}}/releases
129143
as the result of the Continuous-Integration process.
130-
- I.e., they are built right from the source code during every git tagging commit automatically by [travis-ci](https://travis-ci.org/).
144+
- I.e., they are built right from the source code during every git tagging commit automatically.
131145
- Pick & choose the binary executable that suits your OS and its architecture. E.g., for Linux, it would most probably be the `{{.Name}}_linux_VER_amd64` file. If your OS and its architecture is not available in the download list, please let me know and I'll add it.
132146
- You may want to rename it to a shorter name instead, e.g., `{{.Name}}`, after downloading it.
133147

@@ -154,6 +168,8 @@ go get github.com/go-jsonfile/jsonfiddle
154168

155169
All the following similar projects have been considered before writing one on my own instead.
156170

171+
. . . to be filled . . .
172+
157173
## Author(s) & Contributor(s)
158174

159175
Tong SUN

0 commit comments

Comments
 (0)