我正在四處尋找一些與Coldfusion一起工作的最新材料,以將反序列化JSON文件構建到表中。到目前爲止,我使用 的鏈接,例如:在ColdFusion中解析JSON的問題
[土坯反序列化JSON] [1] 我用JSONLINT.com檢查與JSON文件中的任何錯誤(有沒有) 我也看了一下例子在上面的鏈接,發現它會拋出一個CF錯誤如下所示[輸入圖像描述] [2]
我只是想解析來自另一本地服務器的數據,我使用上面的鏈接代碼作爲參考。 當我複製並粘貼代碼確切地說,它導致我的CF錯誤: 如果你可以帶我到任何更多的文件,可以幫助我征服這個問題? 我通常通過ColdFusion的創建在SQLdatabase從數據頁與CFdump的優勢,我想嘗試做不同的
<!--- Get the JSON Feed --->
<cfhttp url="http://localhost:8500/LearnJS/dataconv.cfm">
<!--- JSON data is sometimes distributed as a JavaScript function.
The following REReplace functions strip the function wrapper. --->
<cfset theData=REReplace(cfhttp.FileContent,
"^\s*[[:word:]]*\s*\(\s*","")>
<cfset theData=REReplace(theData, "\s*\)\s*$", "")>
<!--- Test to make sure you have JSON data. --->
<cfif !IsJSON(theData)>
<h3>The URL you requested does not provide valid JSON</h3>
<cfdump var="#theData#">
<!--- If the data is in JSON format, deserialize it. --->
<cfelse>
<cfset cfData = DeserializeJSON(theData)>
<!--- Parse the resulting array or structure and display the data.
In this case, the data represents a ColdFusion query that has been
serialized by the SerializeJSON function into a JSON structure with
two arrays: an array column names, and an array of arrays,
where the outer array rows correspond to the query rows, and the
inner array entries correspond to the column fields in the row. --->
<!--- First, find the positions of the columns in the data array. --->
<cfset colList=ArrayLen(cfData.COLUMNS)>
<cfset cityIdx=ListFind(colList, "City")>
<cfset tempIdx=ListFind(colList, "Temp")>
<cfset fcstIdx=ListFind(colList, "Forecasts")>
<!--- Now iterate through the DATA array and display the data. --->
<cfoutput>
<cfloop index="i" from="1" to="#ArrayLen(cfData.DATA)#">
<h3>#cfData.DATA[i][cityIdx]#</h3>
Current Temperature: #cfData.DATA[i][tempIdx]#<br><br>
<b>Forecasts</b><br><br>
<cfloop index="j" from="1" to="#ArrayLen(cfData.DATA[i][fcstIdx])#">
<b>Day #j#</b><br>
Outlook: #cfData.DATA[i][fcstIdx][j].WEATHER#<br>
High: #cfData.DATA[i][fcstIdx][j].HIGH#<br>
Low: #cfData.DATA[i][fcstIdx][j].LOW#<br><br>
</cfloop>
</cfloop>
</cfoutput>
</cfif>
什麼是錯誤信息? –
您使用的是什麼版本的ColdFusion服務器? – Revent
你可以發佈使用類似螢火蟲的原始json字符串嗎? –