From bb7deb584469d93bada63ff1e644a099652dd005 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Mon, 15 Apr 2013 19:03:57 -0500 Subject: [PATCH] timeside/analyzer/core.py: add to_json() to AnalyzerResult --- timeside/analyzer/core.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/timeside/analyzer/core.py b/timeside/analyzer/core.py index 13479a4..99ac45a 100644 --- a/timeside/analyzer/core.py +++ b/timeside/analyzer/core.py @@ -70,6 +70,13 @@ class AnalyzerResult(dict): return self[name] return super(AnalyzerResult, self).__getattr__(name) + def to_json(self): + import simplejson as json + data_dict = {} + for a in ['name', 'id', 'unit', 'value']: + data_dict[a] = self[a] + return json.dumps(data_dict) + class AnalyzerResultContainer(object): def __init__(self, analyzer_results = []): -- 2.39.5