Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.openwrt.org/project/libubox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/sh
diff options
context:
space:
mode:
authorChristian Beier <dontmind@freeshell.org>2018-01-18 23:21:09 +0300
committerJohn Crispin <john@phrozen.org>2018-01-22 11:21:03 +0300
commit9c4aeda96220b3f0d097d153bedd328f71f382bf (patch)
treebf6f5a1a5030a132e092e8f020d41dfe10067bf6 /sh
parent1c08e80313fd487112c48346889cc57badeef751 (diff)
jshn: add functionality to read big JSON
The existing read functionality feeds the complete JSON to jshn as a cmdline argument, leading to `-ash: jshn: Argument list too long` errors for JSONs bigger than ca. 100KB. This commit adds the ability to read the JSON directly from a file if wanted, removing this shell-imposed size limit. Tested on x86-64 and ar71xx. An mmap()-based solution was also evaluated, but found to make no performance difference on either platform. Signed-off-by: Christian Beier <dontmind@freeshell.org>
Diffstat (limited to 'sh')
-rw-r--r--sh/jshn.sh4
1 files changed, 4 insertions, 0 deletions
diff --git a/sh/jshn.sh b/sh/jshn.sh
index 1090814..66baccb 100644
--- a/sh/jshn.sh
+++ b/sh/jshn.sh
@@ -180,6 +180,10 @@ json_load() {
eval "`jshn -r "$1"`"
}
+json_load_file() {
+ eval "`jshn -R "$1"`"
+}
+
json_dump() {
jshn "$@" ${JSON_PREFIX:+-p "$JSON_PREFIX"} -w
}