queryToJson Big Improvements!
One of the few things I’ve managed to give back to the community is my queryToJson apex class, page and example tool. This allows you to host this simple visualforce page on a Salesforce site, send it valid SOQL queries, and get the results back in JSON. I just made some pretty awesome upgrades to it, and it is available for download on the projects page.
– All values are returned URL encoded. This ensures the returned content is always valid JSON.
– Consistent returning of the returnStringSet variable. This means that even if there is an error while processing, that is still returned. So if your app depends on it, it won’t error. It will just be empty.
– Names of queried columns returned in columns key.
– Number of columns queried returned in numColumns key.
– Status of request returned in success key (boolean true or false for easy evaluation).
– Number of records returned in records key.
– Empty values are returned, instead of being removed.
Also, the example code has been updated. It now shows how to analyze the status of the request, iterate over all the queried fields and put the requested data in a nifty table. So download it and check it out.