Xataface 2.0
Xataface Application Framework
Dataface/JSON.php
Go to the documentation of this file.
00001 <?php
00002 class JSON {
00003 
00004         public static function notice($msg){
00005                 return self::json(array('notice'=>$msg, 'success'=>0, 'msg'=>$msg));
00006         }
00007         
00008         public static function warning($msg){
00009                 return self::json(array('warning'=>$msg, 'success'=>0, 'msg'=>$msg));
00010         }
00011         
00012         public static function error($msg){
00013                 return self::json(array('error'=>$msg, 'success'=>0, 'msg'=>$msg));
00014         }
00015         
00016         public static function json($arr){
00017                 import('Services/JSON.php');
00018                 $json = new Services_JSON();
00019                 return $json->encode($arr);
00020                 /*
00021                 if ( is_array($arr) ){
00022                         $out = array();
00023                         foreach ( $arr as $key=>$val){
00024                                 $out[] = "'".addslashes($key)."': ".JSON::json($val);
00025                         }
00026                         return "{".implode(', ', $out)."}";
00027                 } else if ( is_int($arr) || is_float($arr) ){
00028                         return $arr;
00029                 } else if ( is_bool($arr) ){
00030                         return ( $arr?'1':'0');
00031                 } else {
00032                         return "'".addslashes($arr)."'";
00033                 }
00034                 */
00035         }
00036 }
 All Data Structures Namespaces Files Functions Variables Enumerations