Question
Formatting JSON
I am really frustrated right now. I have a method with the
return format as JSON. All fine and good, but the ouptut looks like
this:
[{"KEY":"Grindhouse Trash 03 How to Make a Dirty Movie","STYLELIST1":"|\\| |_| |_ |_","STYLELIST2":"|\\| |_| |_ |_","DISPLAYTYPEID":0,"PRODUCTSEQUENCE":"|\\| |_| |_ |_","DISPLAYPRODUCTSKUS":[{"STOCKSTATUSID":1,"STARTSHIPDATE":"10\/11.....and so on.
I somehow need to change that into some variables, the product name and the product id that i will return to the page. I have no idea how to do this. Can someone help me please? Below is my CFC code and my return code on the page.
CFC Code......
<cffunction name="search" access="remote" returnformat="json" output="false" hint="affiliates enter in a string, we bring them back the product info">
<cfargument name="searchString" required="yes"/>
<cfscript>
var resultFilter=null;
var query=null;
var result=null;
resultFilter = CreateObject("component", "COM.tlavideo.results.Filter");
resultFilter.addFilter(prop="specialexclude",val="false");
query=component("COM.tlavideo.results.Query").init(narrowingFilter=resultfilter, searchstring=arguments.searchstring, searchgroup="product");
result=query.getResult(resultgroup="product", pagingneeded="false", pageNum="1", pageSize="50");
return serializeJSON(result.get("productresults"));
</cfscript>
</cffunction>
</cfcomponent>
CODE ON PAGE.....
<cfif structkeyexists(form, "search")>
<cfset affiliatessearch=createobject("component", "affiliates.affiliatestextsearch")>
<cfset result=affiliatessearch.search(form.search)>
<cfoutput>#result#</cfoutput>
</cfif>
[{"KEY":"Grindhouse Trash 03 How to Make a Dirty Movie","STYLELIST1":"|\\| |_| |_ |_","STYLELIST2":"|\\| |_| |_ |_","DISPLAYTYPEID":0,"PRODUCTSEQUENCE":"|\\| |_| |_ |_","DISPLAYPRODUCTSKUS":[{"STOCKSTATUSID":1,"STARTSHIPDATE":"10\/11.....and so on.
I somehow need to change that into some variables, the product name and the product id that i will return to the page. I have no idea how to do this. Can someone help me please? Below is my CFC code and my return code on the page.
CFC Code......
<cffunction name="search" access="remote" returnformat="json" output="false" hint="affiliates enter in a string, we bring them back the product info">
<cfargument name="searchString" required="yes"/>
<cfscript>
var resultFilter=null;
var query=null;
var result=null;
resultFilter = CreateObject("component", "COM.tlavideo.results.Filter");
resultFilter.addFilter(prop="specialexclude",val="false");
query=component("COM.tlavideo.results.Query").init(narrowingFilter=resultfilter, searchstring=arguments.searchstring, searchgroup="product");
result=query.getResult(resultgroup="product", pagingneeded="false", pageNum="1", pageSize="50");
return serializeJSON(result.get("productresults"));
</cfscript>
</cffunction>
</cfcomponent>
CODE ON PAGE.....
<cfif structkeyexists(form, "search")>
<cfset affiliatessearch=createobject("component", "affiliates.affiliatestextsearch")>
<cfset result=affiliatessearch.search(form.search)>
<cfoutput>#result#</cfoutput>
</cfif>
