summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@also>2011-07-31 04:28:45 +0200
committertv <tv@also>2011-07-31 04:28:45 +0200
commitbddae8a56d3aa23bd47055e8d0bcb587daab4f6e (patch)
treea2f7b5a47dd5af93f76b08c992b8069a3c195685
parente20df07553f6e3ceba0b87b5c2ab6f3b0a28ab54 (diff)
json/sh: add support for floats
-rwxr-xr-xjson/sh/json.sh2
-rw-r--r--json/sh/test.json3
2 files changed, 3 insertions, 2 deletions
diff --git a/json/sh/json.sh b/json/sh/json.sh
index 8297a853..5d6476ac 100755
--- a/json/sh/json.sh
+++ b/json/sh/json.sh
@@ -22,7 +22,7 @@ json_to_sh() {
s/\{/begin_json_object;/g; s/\}/end_json_object;/g
s/("[^"]+"):/json_set_key \1;/g
s/;("[^"]+")/;json_set string \1;/g
- s/;([0-9]+)/;json_set number `echo -n \1 | base64`;/g
+ s/;([0-9.]+)/;json_set number `echo -n \1 | base64`;/g
s/;;/;/g
s/;/\n/g
p
diff --git a/json/sh/test.json b/json/sh/test.json
index a0406039..9b4c6312 100644
--- a/json/sh/test.json
+++ b/json/sh/test.json
@@ -2,5 +2,6 @@
"a": "1",
"b": 2,
"c": { "ca": 11, "cb": [1, 2, 3, "42"] },
- "d": {}
+ "d": {},
+ "float": 4.23
}