@classmethod<EOL><INDENT>def from_json(cls, json_obj):<DEDENT>
if isinstance(json_obj, str):<EOL><INDENT>json_obj = json.loads(json_obj)<EOL><DEDENT>time = None<EOL>value = None<EOL>if cls.TIME_FIELD_NAME in json_obj:<EOL><INDENT>time = json_obj[cls.TIME_FIELD_NAME]<EOL><DEDENT>else:<EOL><INDENT>raise InvalidMetricError("<STR_LIT>".format(<EOL>field=cls.TIME_FIELD_NAME))<EOL><DEDENT>if cls.VALUE_FIELD_NAME in json_obj:<EOL><INDENT>value = json_obj[cls.VALUE_FIELD_NAME]<EOL><DEDENT>return cls(time, value)<EOL>
Build a MetricResponse from JSON.

        :param json_obj: JSON data representing a Cube Metric.
        :type json_obj: `String` or `json`
        :throws: `InvalidMetricError` when any of {type,time,data} fields are
        not present in json_obj.