PHP转换成JSON数组
<?php
   class Emp {
       public $name = "";
       public $hobbies  = "";
       public $birthdate = "";
   }
   $e = new Emp();
   $e->name = "sachin";
   $e->hobbies  = "sports";
   $e->birthdate = date('m/d/Y h:i:s a', "8/5/1974 12:20:03 p");
   $e->birthdate = date('m/d/Y h:i:s a', strtotime("8/5/1974 12:20:03"));
   echo json_encode($e);
?>

执行结果

{"name":"sachin","hobbies":"sports","birthdate":"08/05/1974 12:20:03 pm"}

PHP解析JSON数组

<?php 

    $postArray ='[{"data":{"hello":"world"},"type":"1234","date":"2012-10-30 17:6:9","user":"000000000000000","time_stamp":1351587969902}, {"data":{"hello":"world"},"type":"1234","date":"2012-10-30 17:12:53","user":"000000000000000","time_stamp":1351588373519}]';
     
    
    $de_json = json_decode($postArray,TRUE);
      $count_json = count($de_json);
        for ($i = 0; $i < $count_json; $i++)
           {
                //echo var_dump($de_json);
 
                  $dt_record = $de_json[$i]['date'];
                   $data_type = $de_json[$i]['type'];
                  $imei = $de_json[$i]['user'];
                  $message = json_encode($de_json[$i]['data']);

                }

?>


                                                                                                                                                                                                     2015-07-31

GitHub 加速计划 / js / json
41.72 K
6.61 K
下载
适用于现代 C++ 的 JSON。
最近提交(Master分支:1 个月前 )
960b763e 4 个月前
8c391e04 7 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐