Untitled

mail@pastecode.io avatar
unknown
plain_text
10 days ago
463 B
2
Indexable
Never
        $arr = ['name' => 'John', 'surname' => 'Bravo'];
        $json = json_encode($arr);
        $contextBuilder = (new ObjectNormalizerContextBuilder())
            ->withGroups(['deserialize']);

        $encoders = [new JsonEncoder()];
        $normalizers = [new ObjectNormalizer()];
        $serializer = new Serializer($normalizers, $encoders);
        $dataSerialize = $serializer->deserialize($json, Example::class, 'json', $contextBuilder->toArray());
Leave a Comment