
import api_util
import metrics

from protorpc import protojson
from flask import request
from flask.ext.restful import Resource

class MetricsApi(Resource):
  @api_util.auth_required
  def post(self):
    resource = request.get_data()
    metrics_request = protojson.decode_message(metrics.MetricsRequest, resource)

    metrics_response = metrics.SERVICE.get_metrics(metrics_request)

    return protojson.encode_message(metrics_response)


import api_util
import metrics
import json

from protorpc import protojson
from flask import request
from flask.ext.restful import Resource

class MetricsApi(Resource):
  @api_util.auth_required
  def post(self):
    resource = request.get_data()
    metrics_request = protojson.decode_message(metrics.MetricsRequest, resource)

    metrics_response = metrics.SERVICE.get_metrics(metrics_request)

    return json.loads(protojson.encode_message(metrics_response))

Return a JSON payload, rather than stringified JSON
Return a JSON payload, rather than stringified JSON

  
  import api_util
  import metrics
+ import json
  
  from protorpc import protojson
  from flask import request
  from flask.ext.restful import Resource
  
  class MetricsApi(Resource):
    @api_util.auth_required
    def post(self):
      resource = request.get_data()
      metrics_request = protojson.decode_message(metrics.MetricsRequest, resource)
  
      metrics_response = metrics.SERVICE.get_metrics(metrics_request)
  
-     return protojson.encode_message(metrics_response)
+     return json.loads(protojson.encode_message(metrics_response))
  
Return a JSON payload, rather than stringified JSON
## Code Before:

import api_util
import metrics

from protorpc import protojson
from flask import request
from flask.ext.restful import Resource

class MetricsApi(Resource):
  @api_util.auth_required
  def post(self):
    resource = request.get_data()
    metrics_request = protojson.decode_message(metrics.MetricsRequest, resource)

    metrics_response = metrics.SERVICE.get_metrics(metrics_request)

    return protojson.encode_message(metrics_response)

## Instruction:
Return a JSON payload, rather than stringified JSON
## Code After:

import api_util
import metrics
import json

from protorpc import protojson
from flask import request
from flask.ext.restful import Resource

class MetricsApi(Resource):
  @api_util.auth_required
  def post(self):
    resource = request.get_data()
    metrics_request = protojson.decode_message(metrics.MetricsRequest, resource)

    metrics_response = metrics.SERVICE.get_metrics(metrics_request)

    return json.loads(protojson.encode_message(metrics_response))
