小編給大家分享一下json_decode索引為數(shù)字時自動排序問題解決方法,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

創(chuàng)新互聯(lián)于2013年創(chuàng)立,是專業(yè)互聯(lián)網(wǎng)技術服務公司,擁有項目成都網(wǎng)站設計、成都網(wǎng)站建設網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元河津做網(wǎng)站,已為上家服務,為河津各地企業(yè)和個人服務,聯(lián)系電話:18980820575
json_encode 索引為數(shù)字,自動排序問題
使用son_encode 給前端返回數(shù)據(jù),結果順序不對,經(jīng)debug調試,發(fā)現(xiàn)是json_encode 函數(shù)的問題;
{
"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"
}
]
}
}
}解決辦法:在數(shù)字索引前加個空格。如“ 19” “ 18”完美解決問題。
解決方法:變成 " " + 數(shù)字即可,例如:" 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索引為數(shù)字時自動排序問題解決方法”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
網(wǎng)頁標題:json_decode索引為數(shù)字時自動排序問題解決方法
URL地址:http://chinadenli.net/article40/pgeceo.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供微信公眾號、品牌網(wǎng)站制作、搜索引擎優(yōu)化、ChatGPT、電子商務、Google
聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)