json_decode 索引为数字时自动排序问题解决方法
网络编程 2021-07-04 15:02www.168986.cn编程入门
这篇文章主要介绍了使用son_encode 给前端返回数据,结果顺序不对,经debug调试,发现是json_encode 函数的问题,变成 " " + 数字即可,需要的朋友可以参考下
json_encode 索引为数字,自动排序问题
使用son_encode 给前端返回数据,结果顺序不对,经debug调试,发现是json_encode 函数的问题;
{ "code": 0, "msg": "请求成功!", "data": { "2018-10": { "17": [ { "id": 730, "uid": "118209", "is_read": false, "biggest_high": 0, "first_read_at": "", "stock_name": "长春燃气", "stock_code": "600333", "in_timed_at": 1539756681, "price": "6.4" } ], "18": [ { "id": 735, "uid": "118209", "is_read": false, "biggest_high": 0, "first_read_at": "", "stock_name": "天孚通信", "stock_code": "300394", "in_timed_at": 1539828137, "price": "17.7" } ], "19": [ { "id": 748, "uid": "118209", "is_read": false, "biggest_high": 0, "first_read_at": "", "stock_name": "科大讯飞", "stock_code": "002230", "in_timed_at": 1539941525, "price": "31.87" } ], "09": [ { "id": 706, "uid": "118209", "is_read": false, "biggest_high": 0, "first_read_at": "", "stock_name": "温州宏丰", "stock_code": "300283", "in_timed_at": 1539048922, "price": "4.83" } ] }, "2018-09": { "29": [ { "id": 702, "uid": "118209", "is_read": false, "biggest_high": 0, "first_read_at": "", "stock_name": "新美星", "stock_code": "300509", "in_timed_at": 1538212392, "price": "13.36" } ] } } }
解决办法在数字索引前加个空格。如“ 19” “ 18”完美解决问题。
解决方法变成 " " + 数字即可,例如" 18", " 19"
{ "code": 0, "msg": "请求成功!", "data": { "2018-10": { " 19": [ { "id": 748, "uid": "118209", "is_read": false, "biggest_high": 0, "first_read_at": "", "stock_name": "科大讯飞", "stock_code": "002230", "in_timed_at": 1539941525, "price": "31.87" } ], " 18": [ { "id": 735, "uid": "118209", "is_read": false, "biggest_high": 0, "first_read_at": "", "stock_name": "天孚通信", "stock_code": "300394", "in_timed_at": 1539828137, "price": "17.7" } ], " 17": [ { "id": 730, "uid": "118209", "is_read": false, "biggest_high": 0, "first_read_at": "", "stock_name": "长春燃气", "stock_code": "600333", "in_timed_at": 1539756681, "price": "6.4" } ], " 09": [ { "id": 706, "uid": "118209", "is_read": false, "biggest_high": 0, "first_read_at": "", "stock_name": "温州宏丰", "stock_code": "300283", "in_timed_at": 1539048922, "price": "4.83" } ] }, "2018-09": { " 29": [ { "id": 702, "uid": "118209", "is_read": false, "biggest_high": 0, "first_read_at": "", "stock_name": "新美星", "stock_code": "300509", "in_timed_at": 1538212392, "price": "13.36" } ] } } }
到此这篇关于json_decode 索引为数字时自动排序问题解决方法的文章就介绍到这了,更多相关json_decode 数字索引自动排序内容请搜索狼蚁SEO以前的文章或继续浏览狼蚁网站SEO优化的相关文章希望大家以后多多支持狼蚁SEO!
上一篇:JS实现滑动拼图验证功能完整示例
下一篇:JS中FormData类实现文件上传
编程语言
- 如何快速学会编程 如何快速学会ug编程
- 免费学编程的app 推荐12个免费学编程的好网站
- 电脑怎么编程:电脑怎么编程网咯游戏菜单图标
- 如何写代码新手教学 如何写代码新手教学手机
- 基础编程入门教程视频 基础编程入门教程视频华
- 编程演示:编程演示浦丰投针过程
- 乐高编程加盟 乐高积木编程加盟
- 跟我学plc编程 plc编程自学入门视频教程
- ug编程成航林总 ug编程实战视频
- 孩子学编程的好处和坏处
- 初学者学编程该从哪里开始 新手学编程从哪里入
- 慢走丝编程 慢走丝编程难学吗
- 国内十强少儿编程机构 中国少儿编程机构十强有
- 成人计算机速成培训班 成人计算机速成培训班办
- 孩子学编程网上课程哪家好 儿童学编程比较好的
- 代码编程教学入门软件 代码编程教程