Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Work on the json(3) documentation.

  • Loading branch information...
commit 0c64956a6c661cdbf6f0d2cf07663fac533f7aa6 1 parent 4b4501b
@freeformsystems authored
Showing with 26 additions and 5 deletions.
  1. +15 −5 lib/modules/json
  2. +3 −0  lib/modules/tasks/npm
  3. +8 −0 man/json.3
View
20 lib/modules/json
@@ -21,11 +21,16 @@ The json(3) module adds methods for parsing and creating JSON documents.
# parse a json string
json.parse <<< '{ "data": "value" }';
json.print;
+
+ # clean up parsed json data
+ json.clean;
## BUGS
**json** is written in bash and depends upon `bash` >= 4.
+The json(3) module is derived from json-sh(1).
+
## COPYRIGHT
**json** is copyright (c) 2012 muji <http://xpm.io>
@@ -44,11 +49,7 @@ function json.parse {
set +o errexit;
set +o nounset;
- # clean any existing data
- for key in "${!json_doc[@]}";
- do
- unset json_doc["$key"];
- done
+ json.clean;
# run the process subsititution in this manner
# to block until the parsing is complete
@@ -91,6 +92,15 @@ function json.print {
done
}
+function json.clean {
+ local key;
+ # clean any existing data
+ for key in "${!json_doc[@]}";
+ do
+ unset json_doc["$key"];
+ done
+}
+
######################################################################
#
# PRIVATE METHODS
View
3  lib/modules/tasks/npm
@@ -6,4 +6,7 @@ function tasks.npm.package.print {
# parse the json package descriptor
json.parse < "$descriptor";
json.print;
+
+ # json.parse <<< '{ "data": "value" }';
+ # json.print;
}
View
8 man/json.3
@@ -20,15 +20,23 @@ require \'json\';
# parse a json document
json\.parse < "${program_dirs[root]}/package\.json";
+json\.print;
# parse a json string
json\.parse <<< \'{ "data": "value" }\';
+json\.print;
+
+# clean up parsed json data
+json\.clean;
.
.fi
.
.SH "BUGS"
\fBjson\fR is written in bash and depends upon \fBbash\fR >= 4\.
.
+.P
+The json(3) module is derived from json\-sh(1)\.
+.
.SH "COPYRIGHT"
\fBjson\fR is copyright (c) 2012 muji \fIhttp://xpm\.io\fR
.
Please sign in to comment.
Something went wrong with that request. Please try again.