Adds a "bare" option to the hatch "set" command indicating to Hatch the
string content should be written as-is instead of encoded as JSON first.
This essentially gives Hatch a text/plain print-to-file option.
Signed-off-by: Bill Erickson <berickxx@gmail.com>
case "set" :
key = request.getString("key");
- // JSON-ify the thing stored under "content"
- String json = JSONObject.valueToString(request.get("content"));
+ String json;
+ if (request.optBoolean("bare", false)) {
+ // Bare strings are stored as-is, no JSON.
+ json = request.getString("content");
+ } else {
+ // JSON-ify the thing stored under "content"
+ json = JSONObject.valueToString(request.get("content"));
+ }
if (!fileIO.set(key, json)) {
response.put("status", 500);