Posts

Showing posts with the label Array

Create Json Array in Javascript Dynamically

This is an example to create Json Array in Javascript dynamically using new Array(), new Object() and .push(). < script > var obj = new Array ( ) ; for ( i = 1 ; i <= 5 ; i ++ ) { var jsonData = new Object ( ) ; jsonData . key = "ID" ; jsonData . value = i ; obj . push ( jsonData ) ; } console . log ( obj ) ; < / script >    

Query Alteration with Coldfusion using Query of Queries (QoQ)

Image
Using alteration in ColdFusion query we can be altered without effecting the identification of a cached query with QOQ. Original Query Output. After Alteration Query Output.

array with struct in coldfusion

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"] ...