Posts
How to parse JSON in coldfusion
- Get link
- X
- Other Apps
Parses the json object and displays the contents of its arrays using DeserializeJSON, This function is useful any time a ColdFusion page receives data as JSON strings. I Type Json: <cfoutput> <cfset JsonData='[{"reason": "email address is unknown", "email": "abc@hotmail.comh"}, {"reason": "email address is unknown", "email": "bbc@68gmail.com"}, {"reason": "email address is unknown", "email": "ff@ff.com"}, {"reason": "Known bad domain", "email": "rr@hotmai.com"}, {"reason": "email address is unknown", "email": "ll@pp.rr.com"}]'> <cfset JsonData=REReplace(JsonData,"^\s*[[:word:]]*\s*\(\s*","")> <cfset JsonData=REReplace(JsonData, "\s*\)\s*$", "")> <cfset cfData=DeserializeJ...
Insert multiple rows at a time in database
- Get link
- X
- Other Apps
We can insert multiple rows in data using one query.It reduce the number of times execute requests. I Type : <Cfquery name="InsertReportDetails" datasource="TestDB"> INSERT INTO UserReporting(UserId,BatchId, ReportId) SELECT #session.UserID#,2,1 UNION SELECT #session.UserID#,2,2 UNION SELECT #session.UserID#,2,3 UNION SELECT #session.UserID#,2,4 </Cfquery> II Type : <Cfquery name="InsertReportDetails" datasource="TestDB"> INSERT INTO UserReporting(UserId,BatchId, ReportId) VALUES (#session.UserI...
Connect to database in php using class with constructor
- Get link
- X
- Other Apps
array with struct in coldfusion
- Get link
- X
- Other Apps
array with struct - Create Json using array with struct in coldfusion <cfquery name="GetUsers" datasource="TestDB"> SELECT UserID, UserName,Active, CASE Active WHEN 1 THEN 'Active' WHEN 0 THEN 'InActive' END AS Status FROM shema_users </cfquery> <cfset resultStruct = Structnew() /> <cfset JsonArray = ArrayNew(1) /> <cfset Counter=1> <cfloop query="GetUsers"> <CFSET color = FormatBaseN(RandRange(0,255), 16) & FormatBaseN(RandRange(0,255), 16) & FormatBaseN(RandRange(0,255), 16)> <cfset JsonArray[Counter] = Structnew() /> <cfset JsonArray[Counter]["UserID"] = "#UserID#" /> <cfset JsonArray[Counter]["UserName"] = "#UserName#" /> <cfset JsonArray[Counter]["Active"] ...