1. 程式人生 > >wx.request得到的正文字段如何處理成符合JSON格式的

wx.request得到的正文字段如何處理成符合JSON格式的

json格式 nothing strong 報錯 orm include 英文 單引號 nbsp

thestr=replace(str,chr(13)&chr(10),"") ‘把換行過濾
thestr=replace(thestr," ","") ‘把空格過濾
thestr=replace(thestr,"/include/editor/","https://圖片存放服務器/include/editor/") ‘把正文中的圖片路徑處理成絕對路徑以便正常顯示
thestr=FormatStr(thestr) ‘把雙引號改成單引號

‘================================================
‘將英文雙引號變成中文雙引號
‘================================================


Function FormatStr(jnkcV)
Dim jnkcTmp,jnkcRegExp
jnkcTmp = jnkcV & ""
Set jnkcRegExp = new RegExp
jnkcRegExp.IgnoreCase = True
jnkcRegExp.Global = True
jnkcRegExp.Pattern = """([^""]*)"""
jnkcTmp = jnkcRegExp.Replace(jnkcTmp,"“$1”")
Set jnkcRegExp = Nothing
FormatStr = jnkcTmp
End Function

至少要處理以上幾個細節後才不會報錯,我剛學微信小程序,邊學邊實踐小項目,被這個問題卡了好久,通過以上粗糙方法暫且可解決,能正常顯示不會報錯了。

wx.request得到的正文字段如何處理成符合JSON格式的