-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson.php
More file actions
executable file
·45 lines (43 loc) · 1014 Bytes
/
json.php
File metadata and controls
executable file
·45 lines (43 loc) · 1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace App\Api;
class json
{
public static function _out($data, $flag = 0, int $depth = 512)
{
$out = json_encode($data, $flag, $depth);
if (self::_is($out)) return $out;
else return self::_out($out);
}
public static function _in($data, $associative = null, int $depth = 512, int $flags = 0)
{
$out = json_decode($data, $associative, $depth, $flags);
return $out;
}
public static function _is($string)
{
if (is_numeric($string))
{
if (is_object($string) === false)
{
return false;
}
else
{
return true;
}
}
elseif (is_array($string))
{
return false;
}
elseif (is_object($string))
{
return false;
}
else
{
json_decode($string);
return json_last_error() === JSON_ERROR_NONE;
}
}
}