- array_map: documentation ( source)
- json_decode: documentation ( source)
- array_column: documentation ( source)
- json_encode: documentation ( source)
<?php
$json = '[{"id":"331","file_name":"3b1379e2496408dd4c865f5f63f96bf6","file_path":"https://path/3b1379e2496408dd4c865f5f63f96bf6.png"},
{"id":"332","file_name":"d0ef559473a061086592bceed0880a01","file_path":"https://path/d0ef559473a061086592bceed0880a01.png"}]';
$arr = json_decode($json, true);
$output = array_map(fn($value) => (object) ['url' => $value], array_column($arr, 'file_path'));
echo json_encode($output);