/*
Creates the JSON body for the commit request.
180159
private String getCommitBody(List<BoxFileUploadSessionPart> parts, Map<String, String> attributes) {
        JsonObject jsonObject = new JsonObject();

        JsonArray array = new JsonArray();
        for (BoxFileUploadSessionPart part: parts) {
            JsonObject partObj = new JsonObject();
            partObj.add("part_id", part.getPartId());
            partObj.add("offset", part.getOffset());
            partObj.add("size", part.getSize());

            array.add(partObj);
        }
        jsonObject.add("parts", array);

        if (attributes != null) {
            JsonObject attrObj = new JsonObject();
            for (String key: attributes.keySet()) {
                attrObj.add(key, attributes.get(key));
            }
            jsonObject.add("attributes", attrObj);
        }

        return jsonObject.toString();
    }
276569
public String buildJson() throws ODataRenderException {
        LOG.debug("Start building Json service root document");
        try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
            JsonGenerator jsonGenerator = JSON_FACTORY.createGenerator(stream, JsonEncoding.UTF8);
            jsonGenerator.writeStartObject();
            jsonGenerator.writeStringField(CONTEXT, getContextURL(uri, entityDataModel));
            jsonGenerator.writeArrayFieldStart(VALUE);


            List<EntitySet> entities = entityDataModel.getEntityContainer().getEntitySets();
            for (EntitySet entity : entities) {
                if (entity.isIncludedInServiceDocument()) {
                    writeObject(jsonGenerator, entity);
                }
            }

            List<Singleton> singletons = entityDataModel.getEntityContainer().getSingletons();
            for (Singleton singleton : singletons) {
                writeObject(jsonGenerator, singleton);
            }

            jsonGenerator.writeEndArray();
            jsonGenerator.writeEndObject();
            jsonGenerator.close();
            return stream.toString(StandardCharsets.UTF_8.name());
        } catch (IOException e) {
            throw new ODataRenderException("It is unable to render service document", e);
        }
    }
52449
public String postJson(String endpoint, JSONObject json) throws IOException {
        return this.postJson(endpoint, "", json);
    }
928209
function xml2json(method, body){
  body = util.xml2json(body);

  if(body.return_code!=='SUCCESS'){
    throw new Error(util.format('api error to call %s: %s', method, body.return_msg));
  }
  if(body.result_code!=='SUCCESS'){
    throw new Error(util.format('business error to call %s: %s %s', method, body.err_code, body.err_code_des));
  }
  return body;
}
1157547
def commit(self):
        '''
        

        '''
        url = self.api_endpoints['send']
        payload = {
            'actions': self._bulk_query,
        }
        payload.update(self._payload)
        self._bulk_query = []

        return self._make_request(
            url,
            json.dumps(payload),
            headers={'content-type': 'application/json'},
        )
1371891
def _construct_from_json(self, rec):
        

        self.delete()

        for required_key in ['dagobah_id', 'created_jobs']:
            setattr(self, required_key, rec[required_key])

        for job_json in rec.get('jobs', []):
            self._add_job_from_spec(job_json)

        self.commit(cascade=True)
790342
def save_to_json(self):
        """"""

        requestvalues = {
            'id': self.dataset,
            'publicationDate': self.publication_date.strftime('%Y-%m-%d'),
            'source': self.source,
            'refUrl': self.refernce_url,
        }        
        return json.dumps(requestvalues)
476160
public String toJson() {
    StringBuilder sb = new StringBuilder("{");
    appendProperty(sb, "branch", branch);

    appendProperty(sb, "commitId", commitId);
    appendProperty(sb, "commitIdAbbrev", commitIdAbbrev);
    appendProperty(sb, "commitTime", commitTime);
    appendProperty(sb, "commitUserName", commitUserName);
    appendProperty(sb, "commitUserEmail", commitUserEmail);
    appendProperty(sb, "commitMessageShort", commitMessageShort);
    appendProperty(sb, "commitMessageFull", commitMessageFull);

    appendProperty(sb, "buildTime", buildTime);
    appendProperty(sb, "buildUserName", buildUserName);
    appendProperty(sb, "buildUserEmail", buildUserEmail);

    appendProperty(sb, "tags", String.join(",", tags));

    appendProperty(sb, "mavenProjectVersion", mavenProjectVersion);

    return sb.append("}").toString();
  }
191846
private ObjectNode createResponseSuccess(String jsonRpc, Object id, JsonNode result) {
		ObjectNode response = mapper.createObjectNode();
		response.put(JSONRPC, jsonRpc);
		if (Integer.class.isInstance(id)) {
			response.put(ID, Integer.class.cast(id).intValue());
		} else if (Long.class.isInstance(id)) {
			response.put(ID, Long.class.cast(id).longValue());
		} else if (Float.class.isInstance(id)) {
			response.put(ID, Float.class.cast(id).floatValue());
		} else if (Double.class.isInstance(id)) {
			response.put(ID, Double.class.cast(id).doubleValue());
		} else if (BigDecimal.class.isInstance(id)) {
			response.put(ID, BigDecimal.class.cast(id));
		} else {
			response.put(ID, String.class.cast(id));
		}
		response.set(RESULT, result);
		return response;
	}
1284702
def _commitData(self, commit):
		
		return {
			"hexsha": commit.hexsha,
			"adate": commit.authored_date,
			"cdate": commit.committed_date,
			"author": "%s <%s>" % (commit.author.name, commit.author.email),
			"message": commit.message
		}
10791
function createResponse(request, response, body){
  return {
    statusCode: response.statusCode,
    statusText: response.statusMessage,
    headers: response.headers,
    originalUrl: request.url,
    effectiveUrl: request.url,
    redirected: false,
    requestMethod: request.method,
    requestHeaders: request.headers,
    body: body,
    retries: 0,
    throttled: false
  };
}
890352
function json (options) {
  var opts = options || {}

  var limit = typeof opts.limit !== 'number'
    ? bytes.parse(opts.limit || '100kb')
    : opts.limit
  var inflate = opts.inflate !== false
  var reviver = opts.reviver
  var strict = opts.strict !== false
  var type = opts.type || 'application/json'
  var verify = opts.verify || false

  if (verify !== false && typeof verify !== 'function') {
    throw new TypeError('option verify must be function')
  }

  // create the appropriate type checking function
  var shouldParse = typeof type !== 'function'
    ? typeChecker(type)
    : type

  function parse (body) {
    if (body.length === 0) {
      // special-case empty json body, as it's a common client-side mistake
      // TODO: maybe make this configurable or part of "strict" option
      return {}
    }

    if (strict) {
      var first = firstchar(body)

      if (first !== '{' && first !== '[') {
        debug('strict violation')
        throw new SyntaxError('Unexpected token ' + first)
      }
    }

    debug('parse json')
    return JSON.parse(body, reviver)
  }

  return function jsonParser (req, res, next) {
    if (req._body) {
      debug('body already parsed')
      next()
      return
    }

    req.body = req.body || {}

    // skip requests without bodies
    if (!typeis.hasBody(req)) {
      debug('skip empty body')
      next()
      return
    }

    debug('content-type %j', req.headers['content-type'])

    // determine if request should be parsed
    if (!shouldParse(req)) {
      debug('skip parsing')
      next()
      return
    }

    // assert charset per RFC 7159 sec 8.1
    var charset = getCharset(req) || 'utf-8'
    if (charset.substr(0, 4) !== 'utf-') {
      debug('invalid charset')
      next(createError(415, 'unsupported charset "' + charset.toUpperCase() + '"', {
        charset: charset
      }))
      return
    }

    // read
    read(req, res, next, parse, debug, {
      encoding: charset,
      inflate: inflate,
      limit: limit,
      verify: verify
    })
  }
}
1287804
private JsonObject toJsonObject() {
        JsonObjectBuilder factory = Json.createObjectBuilder();
        if (idemixCredReq != null) {
            factory.add("request", idemixCredReq.toJsonObject());
        } else {
            factory.add("request", JsonValue.NULL);
        }
        if (caName != null) {
            factory.add(HFCAClient.FABRIC_CA_REQPROP, caName);
        }
        return factory.build();
    }
1078432
protected String serializeBody(Request request)
    {
        try
        {
            return objectMapper.writeValueAsString(request.getRequestBody());
        }
        catch (JsonProcessingException e)
        {
            throw new ClientMarshallingException("Error writing request.",e);
        }
    }
1216276
private void attachJsonBody(final HttpServerExchange exchange, String string) throws IOException {
        Object body;
        if (string != null) {
            string = string.trim();
            if (string.startsWith("{")) {
                body = Config.getInstance().getMapper().readValue(string, new TypeReference<Map<String, Object>>() {
                });
            } else if (string.startsWith("[")) {
                body = Config.getInstance().getMapper().readValue(string, new TypeReference<List<Object>>() {
                });
            } else {
                // error here. The content type in head doesn't match the body.
                setExchangeStatus(exchange, CONTENT_TYPE_MISMATCH, "application/json");
                return;
            }
            exchange.putAttachment(REQUEST_BODY, body);
        }
    }
1229562
public static BoxEntity createEntityFromJson(final JsonObject json){
        JsonValue typeValue = json.get(BoxEntity.FIELD_TYPE);
        if (!typeValue.isString()) {
            return null;
        }
        String type = typeValue.asString();
        BoxEntityCreator creator = ENTITY_ADDON_MAP.get(type);
        BoxEntity entity = null;
        if (creator == null){
            entity = new BoxEntity();
        } else {
            entity = creator.createEntity();
        }
        entity.createFromJson(json);
        return entity;
    }
820049
def build_json(self, guid):
        """"""
        upserts = []
        for value in self.upserts:
            upserts.append({"value": value, "criteria": self.upserts[value]})
        return json.dumps({'replace_all': self.replace_all, 'guid': guid,
                           'complete': self.complete, 'upserts': upserts, 'deletes': self.deletes})