Metric key encode and decode protocol with JSON and namedtuple