这些代码整个是变量$html的值,我现在想把它转换为标准的json格式,最终把它变成一个json数组,便于输出调用!谁能帮我一下?
"data" : {
"price":"20.00",
"skuProps":[{"prop":"颜色",
"skuMap":{"白色L":{"canBookCount":1990},"白M":{"canBookCount":1989},"白色S":{"canBookCount":1988},"白色XL":{"canBookCount":1997},"黑色L":{"canBookCount":1996},"黑色":{"canBookCount":1997}}
}
ä½ è¿ä¸ªä¸å°±æ¯jsonå符串ä¹ï¼
phpéé¢æ2个å½æ°ï¼json_encode å json_decode
æ¥ä¸ä¸æåå°±å¯ä»¥è§£å³äºã
json_decode($str, true) å¯ä»¥å¾å°æ°ç»ï¼ç¬¬äºåæ°ä¸å é»è®¤ä¸ºfalseï¼å¾å°å¯¹è±¡ã追é®
phpéé¢æ2个å½æ°ï¼json_encode å json_decode
æ¥ä¸ä¸æåå°±å¯ä»¥è§£å³äºã
json_decode($str, true) å¯ä»¥å¾å°æ°ç»ï¼ç¬¬äºåæ°ä¸å é»è®¤ä¸ºfalseï¼å¾å°å¯¹è±¡ã追é®
æä¹åæ°æ®æ¯è¿ä¹å¤ççï¼æåäºï¼è¿æ¬¡ä¸ç¥éæä¹äºï¼è¿åçæ¯null
追çå®æ´ä»£ç ä¸ä¼ ä¸æ¥ççï¼åºè¯¥æ¯ä½ æ ¼å¼åéäºã
追é®åºç¡ä¸æå®å®³æ»äººåï¼jsonå符串æå¤é¢ç大æ¬å·è¢«æå æäºï¼éé·ï¼å¼äºä¸å¤©ï¼
温馨提示:答案为网友推荐,仅供参考