php将布尔值类型转为了字符串类型,比如传入"isAnalog":true,处理后"isAnalog":"true"

逗比凯
  • 129

传入参数:{"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"}

需要布尔值不进行转换为字符串类型

回复
阅读 1.7k
1 个回答
温柔的码农
  • 380

PHP 里 json_encode 传入的第一个参数应是数组或关联数组, 你题目中的传入参数不正确, json_encode 返回 json 字符串, js JSON.parse 后为 js 对象(或数组),

宣传栏