Oh my god. It's full of code!

Posts tagged “JSON

Cloudspokes Dynamic Scoreboard Entry Video

Hey all,
Just another demo video of my cloudspokes submission. Basically the contest was to create an HTML and Javascript application that could be displayed on monitors at conventions or contests. It would have three different views (view states) that could be cycled between by modifying a configuration file. Those changes should be loaded with a user having to do anything (since it’s likely this will be on a monitor out in a public area, don’t really want to see someone hitting refresh on the page). So it polls continually for configuration information and changes the contest displayed based on that info. In this video you can see the application as well as the config files and how when I modify them the changes are displayed near without me having to do anything in the browser. Feel free to leave feedback or let me know what you think.

Scoreboard Demo Video

queryToJson Big Improvements!

Hey all.
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.

Example of use

Coldfusion serializeJson preserve case

Hey this is just a quick tip for any of you ColdFusion programmers who may be interacting with javascript while using JSON. ColdFusion being a non case sensative language has an annoying habit of changing the case of your structure key names when being fed through the serializeJson function, or most other functions that translate ColdFusion datastructures. The official statment is that you just need to change your javascript to expect all uppercase key names, but in some cases you cannot do that. There is a workaround however. Instead of declairing your structure keys like

<cfset myStruct = structnew()>
<cfset myStruct.keyName = "I won't preserve this key's case!">
<!---- this will be all uppercase. Sad face 😦 ----->


<cfset myStruct = structnew()>
<cfset myStruct['keyName'] = "I WILL preserve this key's case!">
<!---- this will preserve case. yay! ----->

so even after sending that structure through serializeJson the case of key name in the second example is preserved. Hope this helps someone, cause I know it was driving me crazy for a while!