一、json_decode的使用,json_decode共有4个参数

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

①:$json解析编码为UTF-8编码的字符串

②:$assoc:当该参数为 TRUE 时,将返回数组,FALSE 时返回对象

③:$depth 为递归深度

④:$options   JSON解码选项的位掩码。目前有两种支持的选项。第一个是JSON_BIGINT_AS_STRING允许将大整数转换为字符串而不是浮点数,这是默认值。第二个选项是JSON_OBJECT_AS_ARRAY ,它和设置相同的效果assoc来 TRUE

二:json_encode的使用,不转义中文汉字的方法

①:json_encode($data, JSON_UNESCAPED_UNICODE); //必须PHP5.4+

①:$array = array('lixi'=>'XX');  var_dump(json_encode($array,JSON_UNESCAPED_UNICODE));die;    打印得到  string() "{"lixi":"XX"}"

②:$array = array('lixi'=>'XX');  var_dump(json_encode($array));die;   打印得到  string() "{"lixi":"\u674e\u831c"}"

②:json_encode()只将索引数组(indexed array)转为数组格式,而将关联数组(associative array)转为对象格式。

以上就是这次的全部内容!

json_decode与json_encode容易被忽视的点的更多相关文章

  1. php中json_decode()和json_encode()的使用方法

    php中json_decode()和json_encode()的使用方法 作者: 字体:[增加 减小] 类型:转载   json_decode对JSON格式的字符串进行编码而json_encode对变 ...

  2. json_decode()和json_encode()的使用方法

    json_decode对JSON格式的字符串进行编码 json_encode对变量进行 JSON 编码 JS中对JSON的解析 一.JSON字符串转换为JSON对象     要运用上面的str1,必须 ...

  3. json_decode 与 json_encode 的区别

    1.json_decode对JSON格式的字符串进行编码 2.json_encode对变量进行 JSON 编码 3.unset()是注销定义的变量 4.urlencode()函数原理就是首先把中文字符 ...

  4. php 中json_decode()和json_encode()的使用方法

    1.json_decode() json_decode (PHP 5 >= 5.2.0, PECL json >= 1.2.0) json_decode — 对 JSON 格式的字符串进行 ...

  5. php中json_decode()和json_encode()

    1.json_decode() json_decode (PHP 5 >= 5.2.0, PECL json >= 1.2.0) json_decode — 对 JSON 格式的字符串进行 ...

  6. 【PHP】php中json_decode()和json_encode()

    1.json_decode() json_decode (PHP 5 >= 5.2.0, PECL json >= 1.2.0) json_decode — 对 JSON 格式的字符串进行 ...

  7. json_decode()和json_encode()区别----2015-0929

    json_decode对JSON格式的字符串进行编码而json_encode对变量进行 JSON 编码,需要的朋友可以参考下   1.json_decode() json_decode (PHP 5 ...

  8. json_decode 和 json_encode 区别

    json_decode: json字符串转json对象json_encode: json对象转json字符串 json对象: { "id": 68, "order_no& ...

  9. json_decode和json_encode

    JSON出错:Cannot use object of type stdClass as array解决方法php再调用json_decode从字符串对象生成json对象时,如果使用[]操作符取数据, ...

随机推荐

  1. vb编程中的is是什么意思??

    在select case 语句中可以使用关系运算符大于>小于<等于=等关系运算符,需要用关键字IS和TO.用个例子来说明:Private Sub Command1_Click()Dim a ...

  2. HDU4460

    #include <iostream> #include <queue> #include <vector> #include <cstring> #i ...

  3. Mysql双主互备+keeplived高可用架构介绍

    一.Mysql双主互备+keeplived高可用架构介绍 Mysql主从复制架构可以在很大程度保证Mysql的高可用,在一主多从的架构中还可以利用读写分离将读操作分配到从库中,减轻主库压力.但是在这种 ...

  4. Jmeter监控服务器-CPU,Memory,Disk,Network性能指标

    本文主要说一下如何通过JMeter插件来监控服务器CPU.内存.磁盘.网络等相关资源. 一.下载 首先进入网址https://jmeter-plugins.org/downloads/old/  下载 ...

  5. 微信浏览器里在底部的输入框,ios11的不会被遮盖、10.1会被盖住

    /** * 由于ios10 和 ios11 版本之间的差异,所以先判断ios系统版本之后再做处理 */ let str = navigator.userAgent.toLowerCase(); let ...

  6. Django自定义过滤器及标签

    一.自定义过滤器 1.自定义过滤器文件存放位置 在APP应用下创建名为templatetags(该文件夹名固定)的文件包(包含__init__.py文件) 注意APP必须在setting中注册 即在s ...

  7. Document.write和 getElementById(ID)

    在javascript中,document.write()方法:常用来网页向文档中输出内容. 示例:通过document.write()方法,向网页文档中输出了一段文字. document.write ...

  8. HDU 6348 序列计数 (树状数组 + DP)

    序列计数 Time Limit: 4500/4000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Subm ...

  9. java 调用 api接口

    /* * Copyright 2018 textile.com All right reserved. This software is the * confidential and propriet ...

  10. 1.准备工作之Groovy

    Groovy(读做:gu : ru : wei) Groovy是一种运行在jvm上的动态语言,它吸取了Python.Ruby和SmallTalk等语言的优点:在Java的基础之上增加了许多特色功能,相 ...