Use MD_STD::json_encode over general \json_encode()

This commit is contained in:
Joshua Ramon Enslin 2023-11-27 01:33:53 +01:00
parent d9a0985feb
commit b4c941f441
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -53,11 +53,9 @@ function getNames(array $data):array {
// Q6256 => country
$targets = [
/*
'Q6256' => 'countries',
'Q3024240' => 'historical_countries',
'Q10864048' => 'first_lvl_administrative_units',
*/
];
$langs = ['ar', 'bg', 'bn', 'cs', 'da', 'de', 'el', 'en', 'es', 'fa', 'fi', 'fr', 'ha', 'he', 'hi', 'hu', 'id', 'it', 'ja', 'ka', 'ko', 'nl', 'pl', 'pt', 'ro', 'ru', 'sv', 'sw', 'ta', 'th', 'tl', 'tr', 'uk', 'ur', 'vi', 'zh'];
@ -66,7 +64,7 @@ foreach ($langs as $lang) {
foreach ($targets as $qid => $filename) {
$regionNames = getNames(query($lang, $qid));
file_put_contents(__DIR__ . '/../static/' . $filename . '.' . $lang . '.json', json_encode($regionNames));
file_put_contents(__DIR__ . '/../static/' . $filename . '.' . $lang . '.json', MD_STD::json_encode($regionNames));
echo "Fetched $lang : $filename ($qid)" . PHP_EOL;
}
@ -96,6 +94,6 @@ $mergedValues['cardinal_directions'][] = 'Süd';
foreach ($mergedValues as $filename => $values) {
file_put_contents(__DIR__ . '/../static/' . $filename . '.json', json_encode(array_values(array_unique($values))));
file_put_contents(__DIR__ . '/../static/' . $filename . '.json', MD_STD::json_encode(array_values(array_unique($values))));
}