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
AgeCommit message (Collapse)Author
2023-04-15jshn.sh: Add pretty-printing to json_dumpPhilip Prindeville
If a JSON file might be read by a human, say for debugging, it could be useful to pretty-print it. We do this in places by calling "json_dump -i" but it shouldn't be necessary to know the arguments to "jshn" (and indeed, that's not portable if we retool the underlying implementation). Conversely output that's ephemeral doesn't need to be pretty (say being piped as input to another command). Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2022-09-27jshn.sh: add json_add_fields function for adding multiple fields at onceFelix Fietkau
This simplifies passing extra object data as a function parameter Signed-off-by: Felix Fietkau <nbd@nbd.name>
2018-02-08sh/jshn.sh: add json_for_each_item()Hans Dedecker
Function usefull to iterate through the different elements of an array or object; the provided callback function is called for each element which is passed the value, key and user provided arguments. For field types different from array or object the callback is called with the retrieved value. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com> Acked-by: Jo-Philipp Wich <jo@mein.io>
2018-01-22jshn: add functionality to read big JSONChristian Beier
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>
2018-01-07jshn: properly support JSON "null" typeJo-Philipp Wich
Instead of abort parsing, properly deal with "null" values by implementing support for reading and formatting such values. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2014-11-24Revert "jshn: only keep UP_* variables around while they are needed"Felix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-11-23jshn: shorten JSON_VAR to J_VFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-11-23jshn: shorten variable names to speed up processingFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-11-23jshn: remove TYPE_JSON_VARFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-11-23jshn: do not export JSON_SEQFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-11-23jshn: only keep UP_* variables around while they are neededFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-11-23jshn: improve performance by using let instead of $(( ))Felix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-07-16jshn: do not collapse whitespace in json_load()Jo-Philipp Wich
When running the test case below the $key variable holds "foo bar" instead of the expected "foo bar". -- 8< -- . /usr/share/libubox/jshn.sh json_init json_load '{ "key": "foo bar" }' json_get_var key key -- >8 -- Quote the output of the "jshn -r" backtick expression to prevent the shell from erroneously collapsing whitespace. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2014-04-26sh/jshn.sh - json_cleanup() dont pollute env with local varsBastian Bittorf
this script is mostly sourced, so we should try to keep the pollution of the users environment as low as possible. make the var 'tmp' local Signed-off-by: Bastian Bittorf <bittorf@bluebottle.com>
2014-02-02jshn: drop json_select warnings when called from json_get_values()Felix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-12-10jshn: add ability to pass default values to json_get_var and json_get_varsJo-Philipp Wich
2013-12-02jshn: in json_get_values(), handle json_select errorsFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-12-02jshn: optimize the shell code some moreFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-30jshn: refactor _jshn_append to require fewer evalsFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-30jshn: improve performance by getting rid of unnecessary variables in parser ↵Felix Fietkau
related code Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-30jshn: do not export SEQ_*Felix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-30jshn: get rid of the table stack, use the UP_* variable instead to speed up ↵Felix Fietkau
processing Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-30jshn: reduce the number of appends to the cleanup list to speed up ↵Felix Fietkau
processing of large json files Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-29jshn: allow json_get_keys/values to refer to the currently selected ↵Felix Fietkau
array/table if no argument is given Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-29jshn: add json_get_values (useful for arrays)Felix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-20jshn: add json_get_keys()Felix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-03-17jshn: add support for the double datatypeFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-01-17rename internal variables in json_get_typeLuka Perkov
Signed-off-by: Luka Perkov <luka@openwrt.org>
2013-01-04sanitize json_get_type functionLuka Perkov
Signed-off-by: Luka Perkov <luka@openwrt.org>
2012-12-18jshn: fix check to reset array sequence counters on cleanupFelix Fietkau
2012-12-17jshn: introduce json_is_a() convenience function to check field types ↵Jo-Philipp Wich
without using a temporary variable
2012-12-16jshn: fix array handlingFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-16jshn: fix some variable handling regressionsFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-16jshn: add support for namespacesFelix Fietkau
Can be used to fix variable namespace clashes in library code using jshn Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-05-30sh/jshn.sh: fix json_get_var() and json_get_type() to not return cached valuesJo-Philipp Wich
2012-05-29sh/jshn.sh: replace "tr" calls with inline substitution, signalize success ↵Jo-Philipp Wich
with return values
2012-05-17sh/jshn.sh: fix allowing numbers in identifiersFelix Fietkau
json_add_generic() needs to handle them as well
2012-05-16sh/jshn.sh: allow numbers in identifiers for json_get_var()Jo-Philipp Wich
When traversing arrays of tables or arrays of array it is required to call json_select # where # is the index of the array item to select. Internally json_select() calls json_get_var() to obtain the correct prefix to populate $JSON_CUR with. However, the "tr" call in json_get_var() incorrectly replaces all digits with underscores, making any lookup for numeric array items fail. The attached patch changes the "tr" expression to allow digits and thus implements the expected behaviour for nested arrays.
2012-05-14jshn.sh: add json_get_vars() wrapper functionFelix Fietkau
2011-09-11same for json_get_varFelix Fietkau
2011-09-11jshn: support using characters in elements that do not conform to shell ↵Felix Fietkau
variable restrictions
2011-08-12jshn: clear more variables on json_init, fix adding array elementsFelix Fietkau
2011-05-31jshn: add an option for printing the json data without a terminating newlineFelix Fietkau
2011-05-24jshn: fix invalid variable reuseFelix Fietkau
2011-05-24jshn: do not use -n on exportFelix Fietkau
2011-05-24add jshnFelix Fietkau