鍍金池/ 問答/PHP  HTML/ php將布爾值類型轉(zhuǎn)為了字符串類型,比如傳入"isAnalog&quo

php將布爾值類型轉(zhuǎn)為了字符串類型,比如傳入"isAnalog":true,處理后"isAnalog":"true"

傳入?yún)?shù):{"cpid":"111","ipid":0,"pointType":1,"isAnalog":true,"scpid":"","name":"","alias":"","isArchive":false,"rangeLower":0,"rangeHigh":1000,"unit":"g","valueType":9,"decimal":2,"dataInterval":1000,"deadZone":0,"sdtZone":0,"dataSourceId":0,"isAlarm":false,"isHHHOn":false,"alarmHHH":1000,"isHHOn":false,"alarmHH":1000,"isHOn":false,"alarmH":1000,"isLOn":false,"alarmL":0,"isLLOn":false,"alarmLL":0,"isLLLOn":false,"alarmLLL":0,"isLogic":false,"express":"","parentId":[0],"modifyTime":1511078370040}

json_encode后:{"cpid":"111","ipid":"0","pointType":"1","isAnalog":"true","scpid":"","name":"","alias":"","isArchive":"false","rangeLower":"0","rangeHigh":"1000","unit":"g","valueType":"9","decimal":"2","dataInterval":"1000","deadZone":"0","sdtZone":"0","dataSourceId":"0","isAlarm":"false","isHHHOn":"false","alarmHHH":"1000","isHHOn":"false","alarmHH":"1000","isHOn":"false","alarmH":"1000","isLOn":"false","alarmL":"0","isLLOn":"false","alarmLL":"0","isLLLOn":"false","alarmLLL":"0","isLogic":"false","express":"","parentId":["0"],"modifyTime":"1511078370040"}

需要布爾值不進(jìn)行轉(zhuǎn)換為字符串類型

回答
編輯回答
青裙

PHP 里 json_encode 傳入的第一個(gè)參數(shù)應(yīng)是數(shù)組或關(guān)聯(lián)數(shù)組, 你題目中的傳入?yún)?shù)不正確, json_encode 返回 json 字符串, js JSON.parse 后為 js 對象(或數(shù)組),

2018年2月27日 11:12