codeblog: JSON, JSON, Jason

Last week, I walked through a bit of a tutorial on how to use data feeds to populate and repeat blocks of html content in html emails for Sailthru’s personalization service.

This past week was all about digging further into JSON feeds and more specific data sets that can be passed into Sailthru’s system via APIs. For example, I needed to re-vamp an confirmation email for a purchase by adding all the different data points from a user’s order into an html email, using JSON and Sailthru’s scripting language: Zephyr. The key difference from last week’s project was that all the data was being passed through as Sailthru’s catchall variable (“vars”) via an API call, which was triggered at the time the email gets sent (the “Send API”). The coding was very similar, but because it wasn’t a static feed, I had to set it up with dummy data in order to test it (which was actually a very different process than previous tests I had done).

In another JSON-focused project I worked on this week, I had to figure out the best way to edit a client’s feed so that it was easier to parse for populating data into an Sailthru’s email system, while also making it more stable for any future additions or changes. The original feed (which you can view here) was not well-optimized for either of those concerns. Making matters a bit more complex, the client is a Mexican ecommerce company, so explaining the changes to them was more difficult since English was not their native language. I figured they could probably speak better in code than in English, so we decided to just go ahead and re-vamp their entire feed the way we wanted it. The end result looks like this:

It was a somewhat long and arduous process, but I liked it because I had to re-think the JSON format and come up with a better way to structure it rather than just working with what was already done. As such, I had to think about when we needed to use arrays and when it was better to use key-value pairs.

When parsing and working with JSON, there are a few tools that are pretty helpful. My favorite is the JSON Formatter Chrome extension. There are a few others out there, but this one works well for me. When sharing code snippets, I also have used a few different options including tohtml.com, Pastebin, Gist, Pastie, and Slexy.

And how can I end a post on JSON without a few Jason gifs?

jason_2
jason

The post codeblog: JSON, JSON, Jason first appeared on WHITperson.com.