From: Paul Brossier Date: Tue, 16 Apr 2013 00:03:57 +0000 (-0500) Subject: timeside/analyzer/core.py: add to_json() to AnalyzerResult X-Git-Tag: 0.5.0~115^2~5 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=bb7deb584469d93bada63ff1e644a099652dd005;p=timeside.git timeside/analyzer/core.py: add to_json() to AnalyzerResult --- 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 = []):