code: public function serialize(Map $map, $object)
      {
          $properties = $map->getProperties();
          $data       = $this->prepareData($map, $object);
          $content    = [];
          foreach ($data as $localProperty => $value) {
              $value                                = serialize($value);
              $content[$properties[$localProperty]] = $value;
          }
          return json_encode((object)$content);
      }
docs: Serializes Object
  
  @param Map   $map    the object structure map
  @param mixed $object candidate to serialize
  
  @return mixed