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
Copy file name to clipboardExpand all lines: README.e.md
+20Lines changed: 20 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -59,6 +59,26 @@ This is why `jsonfiddle esc` is a command on its own, instead of being part of f
59
59
60
60
#### > {{cat "test/CustomerSI.ref" | color "json"}}
61
61
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"}}
Copy file name to clipboardExpand all lines: README.md
+41-1Lines changed: 41 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,8 @@
21
21
-[Format with `jsonfiddle fmt`](#format-with-`jsonfiddle-fmt`)
22
22
-[Pretty print](#pretty-print)
23
23
-[> test/CustomerSI.ref](#-testcustomersiref)
24
+
-[Protect templates in json data](#protect-templates-in-json-data)
25
+
-[> test/CustomerP.ref](#-testcustomerpref)
24
26
-[Compact](#compact)
25
27
-[> test/Customer.ref](#-testcustomerref)
26
28
-[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.
52
54
### $ jsonfiddle
53
55
```sh
54
56
JSON Fiddling
55
-
Version v0.3.0 built on 2017-08-14
57
+
Version v0.4.0 built on 2017-09-09
56
58
57
59
Tool to fiddle with json strings
58
60
@@ -62,6 +64,7 @@ Options:
62
64
-c, --compact Compact JSON data, remove all whitespaces
63
65
--prefix prefix for json string output
64
66
-d, --indent[= ] indent for json string output
67
+
-p, --protect protect {{TEMPLATE}} in JSON data
65
68
-v, --verbose Verbose mode (Multiple -v options increase the verbosity.)
66
69
67
70
Commands:
@@ -82,6 +85,7 @@ Options:
82
85
-c, --compact Compact JSON data, remove all whitespaces
83
86
--prefix prefix for json string output
84
87
-d, --indent[= ] indent for json string output
88
+
-p, --protect protect {{TEMPLATE}} in JSON data
85
89
-v, --verbose Verbose mode (Multiple -v options increase the verbosity.)
86
90
-i, --input *the source to get json string from (mandatory)
87
91
-o, --output the output (default: stdout)
@@ -97,6 +101,7 @@ Options:
97
101
-c, --compact Compact JSON data, remove all whitespaces
98
102
--prefix prefix for json string output
99
103
-d, --indent[= ] indent for json string output
104
+
-p, --protect protect {{TEMPLATE}} in JSON data
100
105
-v, --verbose Verbose mode (Multiple -v options increase the verbosity.)
101
106
-i, --input *the source to get json string from (mandatory)
102
107
-o, --output the output (default: stdout)
@@ -112,6 +117,7 @@ Options:
112
117
-c, --compact Compact JSON data, remove all whitespaces
113
118
--prefix prefix for json string output
114
119
-d, --indent[= ] indent for json string output
120
+
-p, --protect protect {{TEMPLATE}} in JSON data
115
121
-v, --verbose Verbose mode (Multiple -v options increase the verbosity.)
116
122
-i, --input *the source to get json string from (mandatory)
117
123
-o, --output the output (default: stdout)
@@ -127,6 +133,7 @@ Options:
127
133
-c, --compact Compact JSON data, remove all whitespaces
128
134
--prefix prefix for json string output
129
135
-d, --indent[= ] indent for json string output
136
+
-p, --protect protect {{TEMPLATE}} in JSON data
130
137
-v, --verbose Verbose mode (Multiple -v options increase the verbosity.)
131
138
-f, --fmt[=json] the structural format of the input data (json/yaml)
132
139
-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
192
199
}
193
200
```
194
201
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:
0 commit comments