Skip to content

Commit f885f4a

Browse files
committed
Initial implementation
1 parent d33134b commit f885f4a

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/functions.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Technically\Json;
5+
6+
use JsonException;
7+
8+
/**
9+
* @param mixed $value
10+
* @param int $flags
11+
* @param int $depth
12+
* @return string
13+
* @throws JsonException
14+
*/
15+
function json_encode($value, int $flags = 0, int $depth = 512): string {
16+
return \json_encode($value, $flags | JSON_THROW_ON_ERROR, $depth);
17+
}
18+
19+
/**
20+
* @param string $json
21+
* @param bool $associative
22+
* @param int $depth
23+
* @param int $flags
24+
* @return mixed
25+
* @throws JsonException
26+
*/
27+
function json_decode(string $json, bool $associative = false, int $depth = 512, int $flags = 0) {
28+
return \json_decode($json, $associative, $depth, $flags | JSON_THROW_ON_ERROR);
29+
}

0 commit comments

Comments
 (0)