Creates a response using the given object.

@param object the object to respond with
@return the response
434609
private static Response createResponse(Object object) {
    if (object == null) {
      return Response.ok().build();
    }

    if (object instanceof Response) {
      return (Response) object;
    }

    if (object instanceof Response.Status) {
      Response.Status s = (Response.Status) object;
      switch (s) {
        case OK:
          return Response.ok().build();
        case ACCEPTED:
          return Response.accepted().build();
        case NO_CONTENT:
          return Response.noContent().build();
        default:
          return createErrorResponse(
              new S3Exception("Response status is invalid", S3ErrorCode.INTERNAL_ERROR));
      }
    }

    // Need to explicitly encode the string as XML because Jackson will not do it automatically.
    XmlMapper mapper = new XmlMapper();
    try {
      return Response.ok(mapper.writeValueAsString(object)).build();
    } catch (JsonProcessingException e) {
      return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
          .entity("Failed to encode XML: " + e.getMessage()).build();
    }
  }
3122
function(object) {
            // three special objects that we want to treat differently
            if(object == null) {
                return "null";
            }
            if(object.constructor == Date) {
                return this.serialize.date.apply(this, [object]);
            }
            if(object.constructor == Array) {
                return this.serialize.array.apply(this, [object]);
            }
            var pieces = ['{'];
            this.level += 1;
            var key, keyJSON, valueJSON;
            
            var addComma = false;
            for(key in object) {
                if(object.hasOwnProperty(key)) {
                    // recursive calls need to allow for sub-classing
                    keyJSON = OpenLayers.Format.JSON.prototype.write.apply(this,
                                                    [key, this.pretty]);
                    valueJSON = OpenLayers.Format.JSON.prototype.write.apply(this,
                                                    [object[key], this.pretty]);
                    if(keyJSON != null && valueJSON != null) {
                        if(addComma) {
                            pieces.push(',');
                        }
                        pieces.push(this.writeNewline(), this.writeIndent(),
                                    keyJSON, ':', this.writeSpace(), valueJSON);
                        addComma = true;
                    }
                }
            }
            
            this.level -= 1;
            pieces.push(this.writeNewline(), this.writeIndent(), '}');
            return pieces.join('');
        }
667690
private void createResponse() {
        response = new GenericQueryResponse(
            queryErrorObservable.onBackpressureBuffer(),
            queryRowObservable.onBackpressureBuffer(),
            querySignatureObservable.onBackpressureBuffer(),
            queryStatusObservable.onBackpressureBuffer(),
            queryInfoObservable.onBackpressureBuffer(),
            queryProfileInfoObservable.onBackpressureBuffer(),
            currentRequest,
            status,
            requestID,
            clientContextID
        );
    }
885980
public static Reflect onObject(Object object) {
      if (object == null) {
         return new Reflect(null, null);
      }
      return new Reflect(object, object.getClass());
   }
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;
	}
309999
public Result render(Object object) {
        if (object instanceof Renderable) {
            this.content = (Renderable<?>) object;
        } else {
            this.content = new RenderableObject(object);
        }
        return this;
    }
662841
public static <T> T updateObject(T object)
    {
        return SqlClosure.sqlExecute(c -> OrmElf.updateObject(c, object));
    }
811559
public NanoHTTPD.Response getResponse() {
        NanoHTTPD.Response response = null;
        // create response
        try {
            if (this.response != null) {
                response = this.response;
            } else if (view != null) {
                response = NanoHTTPD.newFixedLengthResponse(NanoHTTPD.Response.Status.OK, "text/html", view.renderInLayout());
            } else if (!EdenUtils.isEmpty(content)) {
                response = NanoHTTPD.newFixedLengthResponse(NanoHTTPD.Response.Status.OK, "text/html", content);
            } else if (!EdenUtils.isEmpty(json)) {
                response = NanoHTTPD.newFixedLengthResponse(NanoHTTPD.Response.Status.OK, "application/json", json);
            } else if (contentStream != null) {
                response = NanoHTTPD.newFixedLengthResponse(NanoHTTPD.Response.Status.OK, mimeType, contentStream, contentStream.available());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (response == null) {
            response = NanoHTTPD.newFixedLengthResponse("No Data");
        }
        // set headers
        response.addHeader("Access-Control-Allow-Origin", "*");
        if (headers != null) {
            for (String header : headers.keySet()) {
                response.addHeader(header, headers.get(header));
            }
        }
        // set status
        if (status != null) {
            response.setStatus(status);
        }
        // set mime type
        if (mimeType != null) {
            response.setMimeType(mimeType);
        }
        return response;
    }
1075920
protected void handleUpdatedObject(final Object object) {
		runWithWriteLock(new Runnable() {
			public void run() {
				int index = getFinalEventList().indexOf(object);
				if (index >= 0) {
					getFinalEventList().set(index, object);
				}
			}
		});
	}
103179
protected function getResponse( $key, $object )
    {
        $result = array(
            'jsonrpc'   => '2.0',
            $key        => $object,
        );

        if ( null !== $this->id )
        {
            $result['id'] = $this->id;
        }

        $this->response
             ->setContent( json_encode( $result ) );

        return $this->response;
    }
1355172
@Override
    public byte[] toBytes(Object object)
    {
        Short s = null;
        if (object != null)
        {

            if (object.getClass().isAssignableFrom(String.class))
            {
                s = Short.valueOf(object.toString());
            }
            else
            {
                s = (Short) object;
            }
            return new byte[] { (byte) ((s >> 8) & 0xff), (byte) ((s >> 0) & 0xff), };
        }
        return null;
    }
1031879
def create_response_object(self, service_id, version_number, name, status="200", response="OK", content="", request_condition=None, cache_condition=None):
		""""""
		body = self._formdata({
			"name": name,
			"status": status,
			"response": response,
			"content": content,
			"request_condition": request_condition,
			"cache_condition": cache_condition,
		}, FastlyResponseObject.FIELDS)
		content = self._fetch("/service/%s/version/%d/response_object" % (service_id, version_number), method="POST", body=body)
		return FastlyResponseObject(self, content)
1364728
protected Response getResponse(Object connection, Object responseObject) throws IOException {
        Response response = new Response();
        response.setObject(responseObject);
        response.setContent(externalResponseToString(responseObject));
        return response;
    }
165237
public static Map<String, Object> toMap(Object object) {
        if (object == null) {
            return null;
        }
        return toMap(toJSONString(object));
    }
71291
public static String marshal(Object object) {
        if (object == null) {
            return null;
        }

        try {
            JAXBContext jaxbCtx = JAXBContext.newInstance(object.getClass());

            Marshaller marshaller = jaxbCtx.createMarshaller();
            marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);

            StringWriter sw = new StringWriter();
            marshaller.marshal(object, sw);

            return sw.toString();
        } catch (Exception e) {
        }

        return null;
    }
795787
public final void addObject(Object object) {
        if (object instanceof Iterable) {
            // Iterable
            for (Object o : (Iterable<?>) object) {
                objects.add(o);
            }
        } else if (object.getClass().isArray()) {
            // Array
            for (Object o : (Object[]) object) {
                objects.add(o);
            }
        } else {
            // Single object
            objects.add(object);
        }
    }
681540
public CreateResponse create(CreateRequest request) throws IOException {
        return new CreateResponse(client.doPost(request.toUrl(), request.getBody()));
    }