The body content needs to be a json.
421798
def post_accounts(new_account)
      @options = {path: '/accounts/content',
                  body:  Megam::JSONCompat.to_json(new_account)}.merge(@options)

      request(
        :expects  => 201,
        :method   => :post,
        :body     => @options[:body]
        )
    end
770616
def parse_json_body(req):
    """"""
    content_type = req.headers.get("Content-Type")
    if content_type and core.is_json(content_type):
        try:
            return core.parse_json(req.body)
        except TypeError:
            pass
        except json.JSONDecodeError as e:
            if e.doc == "":
                return core.missing
            else:
                raise
    return {}
972063
def getJson(url):
    """"""
    site = urllib2.urlopen(url, timeout=300)
    return json.load(site)
845570
def json(self):
        
        try:
            return json.loads(self.text)
        except Exception as e:
            raise ContentDecodingError(e)
1346439
def encode_json_body(data):
    
    # support for StringIO / file - like objects
    if hasattr(data, "read"):
        return data

    response.content_type = "application/json; charset=utf-8"

    return json.dumps(
        data,
        indent=4,
        separators=(',', ': ')
    )
539673
def _json_body_(cls):
        
        json = []
        for series_name, data in six.iteritems(cls._datapoints):
            json.append({'name': series_name,
                         'columns': cls._fields,
                         'points': [[getattr(point, k) for k in cls._fields]
                                    for point in data]
                         })
        return json
520831
function jsonBodyParser(options) {
    assert.optionalObject(options, 'options');
    var opts = options || {};

    var override = opts.overrideParams;

    function parseJson(req, res, next) {
        // save original body on req.rawBody and req._body
        req.rawBody = req._body = req.body;

        if (req.getContentType() !== 'application/json' || !req.body) {
            return next();
        }

        var params;

        try {
            params = JSON.parse(req.body, opts.reviver);
        } catch (e) {
            return next(new errors.InvalidContentError('Invalid JSON: ' +
                e.message));
        }

        if (opts.mapParams === true) {
            if (Array.isArray(params)) {
                // if req.params exists, we have url params. we can't map an
                // array safely onto req.params, throw an error.
                if (req.params &&
                    Object.keys(req.params).length > 0 &&
                    !(req.params instanceof Array)) {
                    return next(new errors.InternalServerError(
                        'Cannot map POST body of [Array array] onto req.params'
                    ));
                }
                req.params = params;
            } else if (typeof (params) === 'object' && params !== null) {
                // else, try to merge the objects
                Object.keys(params).forEach(function (k) {
                    var p = req.params[k];

                    if (p && !override) {
                        return;
                    }
                    req.params[k] = params[k];
                });
            } else {
                // otherwise, do a wholesale stomp, no need to merge one by one.
                req.params = params || req.params;
            }
        }

        req.body = params;

        return next();
    }

    var chain = [];

    if (!opts.bodyReader) {
        chain.push(bodyReader(opts));
    }
    chain.push(parseJson);
    return chain;
}
507971
def body(self):
        """"""

        if self._decoded_body == None:
            # Try to decode the JSON body. But raise an error if the
            # content-type is unexpected, or the JSON is invalid.

            raw_content_type = self.request.headers.get("content-type") or ""
            content_type = raw_content_type.split(";")[0].strip().lower()

            if content_type == "application/json":
                try:
                    self._decoded_body = escape.json_decode(self.request.body)
                except:
                    raise oz.json_api.ApiError("Bad JSON body")
            else:
                raise oz.json_api.ApiError("JSON body expected")

        return self._decoded_body
1201838
def parse_json(body)
      buf = {}

      begin
        buf = JSON.parse(body)
      rescue JSON::ParserError
      end

      buf
    end
1236489
def decode_body(body, content_type):
        """"""

        if isinstance(body, dict):
            return body
        else:
            try:
                decoded_body = base64.b64decode(body)
            except:
                return body

            if content_type == 'application/json':
                try:
                    return json.loads(decoded_body)
                except:
                    pass

            return decoded_body
767746
def json(self):
        
        try:
            return self._json
        except AttributeError:
            try:
                self._json = json.loads(self.text)
                return self._json
            except:  # noqa e722
                raise RequestInvalidJSON("Invalid JSON received")
512765
def publish_json(self, channel, obj):
        """"""
        return self.publish(channel, json.dumps(obj))
1076375
def _urlopen_as_json(self, url, headers=None):
        """"""
        req = Request(url, headers=headers)
        return json.loads(urlopen(req).read())
436549
def _parse_body(self, body):
    
    if is_python3():
      return json.loads(body.decode('UTF-8'))
    else:
      return json.loads(body)
323972
def NewFromJSON(data):
        
        s = Shake(
            id=data.get('id', None),
            name=data.get('name', None),
            url=data.get('url', None),
            thumbnail_url=data.get('thumbnail_url', None),
            description=data.get('description', None),
            type=data.get('type', None),
            created_at=data.get('created_at', None),
            updated_at=data.get('updated_at', None)
        )
        if data.get('owner', None):
            s.owner = User.NewFromJSON(data.get('owner', None))
        return s
997365
function remakeBody (body, bodyType) {
  return blobUtil
    .base64StringToBlob(body)
    .then(function (blob) {
      switch (bodyType) {
        case BodyTypes.ARRAY_BUFFER:
          return blobUtil.blobToArrayBuffer(blob)
        case BodyTypes.BLOB:
          return blob
        case BodyTypes.FORM_DATA:
          throw new Error('Cannot make FormData from serialised Request')
        case BodyTypes.JSON:
          return blobToString(blob)
            .then(function (str) {
              return JSON.parse(str)
            })
        case BodyTypes.TEXT:
          return blobToString(blob)
        default:
          throw new Error('Unknown requested body type "' + bodyType + '"')
      }
    })
}
983350
def with_json(self, data=None, **params):
        
        if isinstance(data, (tuple, list)):
            data = dict(data)

        if params:
            # data must be None or able to be a dict
            if isinstance(data, dict):
                data.update(params)
            elif data is None:
                data = params
            else:
                raise ValueError('Data must be None or a dict if used with params, got: %r' % data)

        req = self.with_headers({'Content-Type': 'application/json', 'Accept': 'application/json'})
        if isinstance(data, basestring):
            # Looks like it's already been encoded
            return req.with_body(data)
        else:
            return req.with_body(json.dumps(data))