Skip to content

Commit 183517f

Browse files
committed
- [*] update README
1 parent 0072b34 commit 183517f

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

README.e.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,26 @@ This is why `jsonfiddle esc` is a command on its own, instead of being part of f
5959

6060
#### > {{cat "test/CustomerSI.ref" | color "json"}}
6161

62+
### Protect templates in json data
63+
64+
There are times that json data may contain templates, i.e., strings like `{{"{{VARIABLE}}"}}`. Some of the pretty printing tools, like the json plugin in Notepad++, cannot handle such template forms well, and will turn `{{"{{VARIABLE}}"}}` into:
65+
66+
```json
67+
{
68+
{
69+
VARIABLE
70+
}
71+
}
72+
```
73+
74+
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.
75+
76+
To make such template variables work for those tools, the `-p,--protect` option is introduced:
77+
78+
$ jsonfiddle fmt -p -i test/CustomerP.json
79+
80+
#### > {{cat "test/CustomerP.ref" | color "json"}}
81+
6282
### Compact
6383

6484
$ jsonfiddle fmt -c -i test/Customer.json

README.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
- [Format with `jsonfiddle fmt`](#format-with-`jsonfiddle-fmt`)
2222
- [Pretty print](#pretty-print)
2323
- [> test/CustomerSI.ref](#-testcustomersiref)
24+
- [Protect templates in json data](#protect-templates-in-json-data)
25+
- [> test/CustomerP.ref](#-testcustomerpref)
2426
- [Compact](#compact)
2527
- [> test/Customer.ref](#-testcustomerref)
2628
- [Sort fields with `jsonfiddle sort`](#sort-fields-with-`jsonfiddle-sort`)
@@ -52,7 +54,7 @@ The `jsonfiddle` makes it easy to look at the JSON data from different aspects.
5254
### $ jsonfiddle
5355
```sh
5456
JSON Fiddling
55-
Version v0.3.0 built on 2017-08-14
57+
Version v0.4.0 built on 2017-09-09
5658

5759
Tool to fiddle with json strings
5860

@@ -62,6 +64,7 @@ Options:
6264
-c, --compact Compact JSON data, remove all whitespaces
6365
--prefix prefix for json string output
6466
-d, --indent[= ] indent for json string output
67+
-p, --protect protect {{TEMPLATE}} in JSON data
6568
-v, --verbose Verbose mode (Multiple -v options increase the verbosity.)
6669

6770
Commands:
@@ -82,6 +85,7 @@ Options:
8285
-c, --compact Compact JSON data, remove all whitespaces
8386
--prefix prefix for json string output
8487
-d, --indent[= ] indent for json string output
88+
-p, --protect protect {{TEMPLATE}} in JSON data
8589
-v, --verbose Verbose mode (Multiple -v options increase the verbosity.)
8690
-i, --input *the source to get json string from (mandatory)
8791
-o, --output the output (default: stdout)
@@ -97,6 +101,7 @@ Options:
97101
-c, --compact Compact JSON data, remove all whitespaces
98102
--prefix prefix for json string output
99103
-d, --indent[= ] indent for json string output
104+
-p, --protect protect {{TEMPLATE}} in JSON data
100105
-v, --verbose Verbose mode (Multiple -v options increase the verbosity.)
101106
-i, --input *the source to get json string from (mandatory)
102107
-o, --output the output (default: stdout)
@@ -112,6 +117,7 @@ Options:
112117
-c, --compact Compact JSON data, remove all whitespaces
113118
--prefix prefix for json string output
114119
-d, --indent[= ] indent for json string output
120+
-p, --protect protect {{TEMPLATE}} in JSON data
115121
-v, --verbose Verbose mode (Multiple -v options increase the verbosity.)
116122
-i, --input *the source to get json string from (mandatory)
117123
-o, --output the output (default: stdout)
@@ -127,6 +133,7 @@ Options:
127133
-c, --compact Compact JSON data, remove all whitespaces
128134
--prefix prefix for json string output
129135
-d, --indent[= ] indent for json string output
136+
-p, --protect protect {{TEMPLATE}} in JSON data
130137
-v, --verbose Verbose mode (Multiple -v options increase the verbosity.)
131138
-f, --fmt[=json] the structural format of the input data (json/yaml)
132139
-i, --input *the source of the input JSON (mandatory)
@@ -192,6 +199,39 @@ This is why `jsonfiddle esc` is a command on its own, instead of being part of f
192199
}
193200
```
194201

202+
### Protect templates in json data
203+
204+
There are times that json data may contain templates, i.e., strings like `{{VARIABLE}}`. Some of the pretty printing tools, like the json plugin in Notepad++, cannot handle such template forms well, and will turn `{{VARIABLE}}` into:
205+
206+
```json
207+
{
208+
{
209+
VARIABLE
210+
}
211+
}
212+
```
213+
214+
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.
215+
216+
To make such template variables work for those tools, the `-p,--protect` option is introduced:
217+
218+
$ jsonfiddle fmt -p -i test/CustomerP.json
219+
220+
#### > test/CustomerP.ref
221+
```json
222+
{
223+
"firstName": "<<C_firstName>>",
224+
"lastName": "<<C_lastName>>",
225+
"age": "<<C_age>>",
226+
"address": {
227+
"streetAddress": "<<C_address1>>",
228+
"city": "<<C_city>>",
229+
"state": "NY",
230+
"postalCode": "10021"
231+
}
232+
}
233+
```
234+
195235
### Compact
196236

197237
$ jsonfiddle fmt -c -i test/Customer.json

0 commit comments

Comments
 (0)