File modules/util/json/JSON.class.php

Last commit: Thu Apr 28 00:28:24 2022 +0200	Jan Dankert	New: Login with Json webtoken (JWT)
1 <?php 2 3 4 namespace util\json; 5 6 require(__DIR__.'/../JSON.class.php'); 7 8 /** 9 * JSON Wrapper. 10 */ 11 class JSON 12 { 13 public static function encode($jsonObj) { 14 15 if (function_exists('json_encode')) 16 { 17 // Native Methode ist schneller.. 18 if ( version_compare(PHP_VERSION, '5.5', '>=' ) ) 19 $jsonOptions = JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK | JSON_PARTIAL_OUTPUT_ON_ERROR; 20 else 21 $jsonOptions = JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK; 22 23 return json_encode($jsonObj, $jsonOptions); 24 } 25 else 26 { 27 // Fallback, falls json_encode() nicht existiert... 28 $json = new \JSON(); 29 return $json->encode($jsonObj); 30 } 31 32 } 33 public static function decode($jsonText) { 34 35 if (function_exists('json_decode')) { 36 return json_decode( $jsonText,true ); 37 } else { 38 $json = new JSON(); 39 return $json->decode($jsonText); 40 } 41 } 42 }
Download modules/util/json/JSON.class.php
History Thu, 28 Apr 2022 00:28:24 +0200 Jan Dankert New: Login with Json webtoken (JWT) Wed, 17 Mar 2021 02:18:50 +0100 Jan Dankert Refactoring: Using "Jquery slim" without ajax and effects. Fri, 26 Feb 2021 00:04:49 +0100 Jan Dankert New: Request may contain JSON,XML in POST data. This is good for API clients. Sat, 26 Sep 2020 01:41:20 +0200 Jan Dankert Refactoring: Removing old require.php files. With class autoloading, they are not necessary any more.