Handles serializing an object to json

@param      $object
@param null $view
@return string
772828
private function toJson($object, $view = null)
    {
        return json_encode($this->builder->buildRepresentation($object, $view));
    }
635300
protected function getSerializationContext(View $view)
    {
        $context = parent::getSerializationContext($view);

        if ($this->serializerEnableMaxDepthChecks) {
            $context->enableMaxDepthChecks();
        }

        return $context;
    }
440541
private byte[] json(Object object) {
        try {
            return mapper.writeValueAsBytes(object);
        } catch (JsonProcessingException e) {
            throw new ZendeskException(e.getMessage(), e);
        }
    }
1210193
protected function getSerializationContext(View $view)
    {
        $context = $view->getContext();

        $groups = $context->getGroups();
        if (empty($groups) && $this->exclusionStrategyGroups) {
            $context->setGroups($this->exclusionStrategyGroups);
        }

        if (null === $context->getVersion() && $this->exclusionStrategyVersion) {
            $context->setVersion($this->exclusionStrategyVersion);
        }

        if (null === $context->getSerializeNull() && null !== $this->serializeNullStrategy) {
            $context->setSerializeNull($this->serializeNullStrategy);
        }

        return $context;
    }
720813
public function renderProperty($model, $property, $view, $form = null)
    {
        return $this->render(
            $this->convertView($view),
            [
                'model' => $model,
                'property' => $property,
                'form' => $form
            ]
        );
    }
173604
public function render($view = null)
    {
        if (is_null($view)) {
            $view = config('navigation.view.badge', 'navigation::badge');
        }

        return view($view, $this->toArray());
    }
245503
def object_to_json(obj):
    """"""
    if isinstance(obj, (datetime.datetime, datetime.date, datetime.time)):
        return obj.isoformat()
    return str(obj)
366948
public static function serialize( $object, $fileName )
	{
		$serial	= parent::serialize( $object );
		$file	= new FS_File_Writer( $fileName );
		return $file->writeString( $serial );
	}
974743
protected function getLinks($object, $view)
    {
        $reflection = new \ReflectionClass($object);
        $links = new \stdClass();
        $annot = $this->reader->getClassAnnotation($reflection, '\Represent\Annotations\LinkCollection');

        if ($annot) {
            $links = $this->parseLinks($annot, $view, $links, $object);
        }

        return $links;
    }
28927
public static String serialise(Object object) {
        Gson gson = getBuilder().create();
        return gson.toJson(object);
    }
1159660
private function convertToJson($data)
    {
        if (is_array($data)) {
            return json_encode($data);
        }

        if ($data instanceof Jsonable) {
            return $data->toJson();
        }

        if ($data instanceof Arrayable) {
            return json_encode($data->toArray());
        }

        return null;
    }
776051
public function createView($object)
    {
        foreach ($this->factories as $factory) {
            $view = $factory->createView($object);

            if (null !== $view) {
                return $view;
            }
        }
    }
126555
public function getView(View $view)
    {
        if (!$view instanceof ContentValueView) {
            return null;
        }

        $viewType = $view->getViewType();
        $contentInfo = $view->getContent()->contentInfo;

        $legacyKernel = $this->getLegacyKernel();
        $legacyContentClosure = function (array $params) use ($contentInfo, $viewType, $legacyKernel) {
            return $legacyKernel->runCallback(
                function () use ($contentInfo, $viewType, $params) {
                    $tpl = eZTemplate::factory();
                    /**
                     * @var \eZObjectForwarder
                     */
                    $funcObject = $tpl->fetchFunctionObject('content_view_gui');
                    if (!$funcObject) {
                        return '';
                    }

                    // Used by XmlText field type
                    if (isset($params['objectParameters'])) {
                        if (isset($params['linkParameters']) && $params['linkParameters'] !== null) {
                            $linkParameters = $params['linkParameters'];
                        }
                        $tpl->setVariable('object_parameters', $params['objectParameters'], 'ContentView');
                    }
                    // Used by RichText field type
                    elseif (isset($params['embedParams'])) {
                        if (isset($params['embedParams']['link'])) {
                            $linkParameters = $params['embedParams']['link'];
                        }

                        if (isset($params['embedParams']['config'])) {
                            $tpl->setVariable('object_parameters', $params['embedParams']['config'], 'ContentView');
                        }
                    }

                    // Convert link parameters to Legacy Stack format
                    if (isset($linkParameters)) {
                        $tpl->setVariable(
                            'link_parameters',
                            $this->legalizeLinkParameters($linkParameters),
                            'ContentView'
                        );
                    }

                    $children = [];
                    $funcObject->process(
                        $tpl, $children, 'content_view_gui', false,
                        [
                            'content_object' => [
                                [
                                    eZTemplate::TYPE_ARRAY,
                                    // eZTemplate::TYPE_OBJECT does not exist because
                                    // it's not possible to create "inline" objects in
                                    // legacy template engine (ie objects are always
                                    // stored in a tpl variable).
                                    // TYPE_ARRAY is used here to allow to directly
                                    // retrieve the object without creating a variable.
                                    // (TYPE_STRING, TYPE_BOOLEAN, ... have the same
                                    // behaviour, see eZTemplate::elementValue())
                                    eZContentObject::fetch($contentInfo->id),
                                ],
                            ],
                            'view' => [
                                [
                                    eZTemplate::TYPE_STRING,
                                    $viewType,
                                ],
                            ],
                        ],
                        [], '', ''
                    );
                    if (\is_array($children) && isset($children[0])) {
                        return ezpEvent::getInstance()->filter('response/output', $children[0]);
                    }

                    return '';
                },
                false
            );
        };

        $this->decorator->setContentView(
            new ContentView($legacyContentClosure)
        );

        return $this->decorator;
    }
913814
public function renderJson($data=null)
    {
        $this->beforeRender($data);
        
        $res = ErrorInfo::instance($this->responseData())->all();
        
        foreach ($res as $k => $v) {
            if ($v instanceof Collection) {
                $res[$k] = $v->all();
            }
        }
        
        if ($callback = $this->input('callback')) {
            $string = $callback . '(' . json_encode($res) . ')';
        } else {
            $this->response = $this->response->withHeader('Content-Type', 'application/json;charset=utf-8');
            $string = json_encode($res);
        }
        
        return $this->renderText($string);
    }
681522
public function render($view = null)
    {
        if (is_null($view) and ! isset($this->templatePaths[$this->defaultLanguage])) {
            return '';
        }
        $return   = (is_null($view)) ? view($this->templatePaths[$this->defaultLanguage], $this->predefinedVariables) : view($view, $this->predefinedVariables);
        $adapter  = app(VariablesAdapter::class);
        $rendered = $adapter->fill($return->__toString());
        preg_match_all('/\[\[(.*?)\]\]/', $rendered, $matches);
        if (isset($matches[0]) && isset($matches[1])) {
            foreach ($matches[0] as $index => $variable) {
                $rendered = str_replace($variable, '{{ ' . $matches[1][$index] . ' }}', $rendered);
            }
            $twig = new Twig_Environment(new Twig_Loader_String());
            return $twig->render($rendered, $this->predefinedVariables);
        }

        return $rendered;
    }
1067208
public static String toJSONString(Object object) {
        if (object == null) {
            return null;
        }
        return JSONObject.toJSONString(object);
    }
996642
public function render($view, array $parameters = array(), Response $response = null)
    {
        if ($response === null) {
            $response = new Response();
        }

        $json = Encoder::encodeFromFile($this->getPath($view), $parameters);
        $response->setContent($json);

        return $response;
    }