[{'text':'Jewelry','id':'1',"cls":"folder"},{'text':'Vintage Clothing and Accessories',
'id':'2',"cls":"folder"},
{'text':'Spices','id':'3',"cls":"folder"},
{'text':'Art','id':'4',"cls":"folder"},
{'text':'Collectibles','id':'5',"cls":"folder"},
{'text':'Books','id':'6',"cls":"folder"},
{'text':'Teas','id':'7',"cls":"folder"},
{'text':'Clothing','id':'8',"cls":"folder"},
{'text':'Exercise','id':'10',"cls":"folder"},
{'text':'Send A Little Something','id':'11',"cls":"folder"},
{'text':'My New Category','id':'12',"cls":"folder"},
{'text':'Another New Category','id':'14',"cls":"folder"}]
How do you emulate this response? First you must know what the [ and the { indicate.
The [ indicates you are returning an array. The { indicates you are returning a structure. Since the [ is on the outside, you need to build a structure inside an array.
So first you execute a query. Then you create an array, loop through the query. For each loop create a structure that is appended to the array.
How?
Here is an example:
Load the structure into the array
Increment the index
Continue until the loop is completed
Then all you need to do is return the array users to the calling program
Make sure your function has returnformat="JSON">
I hope this helps. In the future I will post full examples.
No comments:
Post a Comment