<?php

$images = [];

foreach ($page->files() as $image) {
  $images[] = [
    'url' => $image->url(),
    'uuid' => (string) $image->uuid(),
    'tags' => $image->tags()->split(),
    'name' => $image->filename(),
    'description' => $image->description()->value(),
  ];
}

$specificData = [
  "images" => $images
];

$pageData = array_merge($genericData, $specificData);

echo json_encode([
  "page" => $pageData,
  "user" => $userData
]);