mirror of
https://github.com/pi-hole/pi-hole.git
synced 2025-04-21 23:00:18 +00:00
Parse with PHP
This commit is contained in:
parent
4839953328
commit
56bbf3b05c
3 changed files with 147 additions and 108 deletions
20
advanced/Scripts/json.php
Normal file
20
advanced/Scripts/json.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
if ((isset($argv[1])) && (isset($argv[2]))) {
|
||||
$json="$argv[1]";
|
||||
$key="$argv[2]";
|
||||
$result=json_decode($json, true);
|
||||
if (is_array($result)) {
|
||||
if (array_key_exists($key, $result)) {
|
||||
echo "$result[$key]";
|
||||
} else {
|
||||
//key dosnt exist
|
||||
die("Error KEY");
|
||||
}
|
||||
} else {
|
||||
//invalid json
|
||||
die("Error JSON");
|
||||
}
|
||||
} else {
|
||||
die("Usage: php json.php \"JSON DATA HERE\" \"Key\"");
|
||||
}
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue