aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/value-to-json.hh
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-02-19 14:24:04 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-02-19 14:24:04 +0100
commit7a173a7be18e34166bc5ad0195dec1efb3cd22fc (patch)
tree108c093b2ef7de45ae607c953eafb607a9283892 /src/libexpr/value-to-json.hh
parent7251a81bde29fe1a17aa5b29dd74a4200239b010 (diff)
JSONObject: Support floats and booleans
Diffstat (limited to 'src/libexpr/value-to-json.hh')
-rw-r--r--src/libexpr/value-to-json.hh13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/libexpr/value-to-json.hh b/src/libexpr/value-to-json.hh
index f6796f205..c59caf564 100644
--- a/src/libexpr/value-to-json.hh
+++ b/src/libexpr/value-to-json.hh
@@ -36,7 +36,18 @@ struct JSONObject
attr(s);
escapeJSON(str, t);
}
- void attr(const string & s, int n)
+ void attr(const string & s, const char * t)
+ {
+ attr(s);
+ escapeJSON(str, t);
+ }
+ void attr(const string & s, bool b)
+ {
+ attr(s);
+ str << (b ? "true" : "false");
+ }
+ template<typename T>
+ void attr(const string & s, const T & n)
{
attr(s);
str << n;