You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please let me know if I am being ignorant here...is it the case that a Collection cannot have an object at the root level? I thought Serializers existed so that the output format could be manipulated but it seems that the Scope class will only play with arrays.
Specifically, I was a trying to create a custom serializer to output GeoJSON, a standard in which collections are objects at the root level, e.g.:
class GeoJsonSerializer extends SerializerAbstract
{
public function collection($resourceKey, array $data)
{
$featureCollection = new \StdClass();
$featureCollection->type = 'FeatureCollection';
$featureCollection->features = ["foo","bar"]
return $featureCollection; //does not work
//return [$featureCollection]; //does work but wraps FeatureCollection object in array
}
I am not using this with pagination or meta data so I could in theory strip the square brackets from the string after doing $manager->toJson() but it seem like that defeats the point of having a serializer. Please is there some elegant way around this that I am overlooking?
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 4 weeks if no further activity occurs. Thank you for your contributions.
Please let me know if I am being ignorant here...is it the case that a Collection cannot have an object at the root level? I thought Serializers existed so that the output format could be manipulated but it seems that the Scope class will only play with arrays.
Specifically, I was a trying to create a custom serializer to output GeoJSON, a standard in which collections are objects at the root level, e.g.:
I am not using this with pagination or meta data so I could in theory strip the square brackets from the string after doing $manager->toJson() but it seem like that defeats the point of having a serializer. Please is there some elegant way around this that I am overlooking?
The text was updated successfully, but these errors were encountered: