</pre><span style="font-size:24px"></span><pre name="code" class="php">

json_decode

mixed json_decode ( string $json [, bool $assoc = false [, int $depth = 512 [, int $options = 0 ]]] )

接受一个 JSON 格式的字符串而且把它转换为 PHP 变量

json_encode

string json_encode ( mixed $value [, int $options = 0 ] )

返回 value 值的 JSON 形式

比方interface_x 中须要获取interface_y 中传递的数据data,而data中含有特殊字符,就能够在interface_y中把这些特殊字符存入数组,然后json_encode成json

格式的字符串,传递给interface_x。在interface_x中进行json_decode。

$json2 = json_decode($json, true);
//echo "json2:";
//var_dump($json2);

interface_y中对包括特殊字符的字符串进行处理,存入数组。并进行json_encode:

$value = '~!@#$%^&*()_+-={}:";<>?

/\123456789123';
$data = array("key" => $value);
$json = json_encode($data);
//echo "json:" . "\n";
//var_dump($json);

在interface_x中对传入的json数据,进行json_decode成数组。

參考:

http://php.net/manual/zh/function.json-decode.php

http://php.net/manual/zh/function.json-encode.php

最新文章

  1. 字典树+博弈 CF 455B A Lot of Games(接龙游戏)
  2. 简单的方向传感器SimpleOrientationSensor
  3. jsonp原理
  4. mysql 存储过程简介
  5. RabbitMQ的工作队列和路由
  6. 如果浏览器自动调用quirks模式打开的话
  7. 解决ionic在ios无法使用focus,ios focus失效的问题
  8. ajax readyState的五种状态详解
  9. requirejs学习博客址分享
  10. Mina学习之IoBuffer
  11. 武汉科技大学ACM:1006: 华科版C语言程序设计教程(第二版)例题4.17
  12. 使用 C# 编写简易 ASP.NET Web 服务器
  13. Android studio教程:[4]真机测试
  14. 数据库 基于索引的SQL语句优化之降龙十八掌(转)
  15. 进程间通信系列 之 命名管道FIFO及其应用实例
  16. ssh爆破(python脚本)
  17. 【NumberValidators】大陆身份证验证
  18. js获取今天是星期几
  19. Java跨平台的原理
  20. JS--dom对象:document object model文档对象模型

热门文章

  1. 一个简陋的 CSS 样式
  2. spring + jdbc + extjs configuration
  3. 关于使用STL常见的两个bug
  4. Why Hadoop2
  5. BOOST 线程完全攻略 - 基础篇
  6. [跟我学spring学习笔记][更多DI知识]
  7. TRI 解题报告
  8. Win8.1系统下安装nodeJS
  9. [转]Python存取XML方法简介
  10. redis学习研究--基础知识