JSON to XML with AngularJS in Preparation for InDesign

In a recent project, I wanted to use Google Sheets as a content management system: the source for a print layout and a website. I wanted the content to reside in a single, easily editable location.

In order to achieve that outcome, InDesign requires the data in an XML file. But first, I had to convert the JSON data in Google Sheets to XML. This would allow me to customize the tag names to leverage the custom mapping styles feature within InDesign, which would make it a breeze to update the InDesign document as the content of the book changed. Read more on JSON to XML with AngularJS in Preparation for InDesign…

A Tiny Toolbox for Spelunking through JSON

I rely heavily on local instances of a web or mobile application’s API during development. Since I also need to speak fluently with my data on live instances of the API, including both test and production, I’ve found that I often need to work with structured JSON data at the terminal rather than a Javascript-native environment like node.js or browsers. I’ve discovered how important the tools curl, bash, jq, and json-diff can be for this sort of work, so I’d like to share some ways they’ve been useful to me when wrangling JSON at the command-line. Read more on A Tiny Toolbox for Spelunking through JSON…

Dynamic Binding in Ember.js Using Observers

I’m currently working on an Ember.js web application that is a basic CRUD app with a twist — we don’t know all of the form fields or model attributes ahead of time, but rely on a JSON document to specify the names and types of attributes for which we need to render form controls. This presents some interesting challenges, the most significant being that our input elements don’t know what to bind their value to until they are instantiated.

After trying a few different approaches, we settled on using a pair of observers to accomplish what a more direct binding could not in this scenario. One observer watches the input’s value property and updates the remote property value, and the other observer watches the remote property and updates the input’s value.

Our Solution

Read on for a few more details. This example uses Ember.js 1.0.0-RC.1, and we are using the same general solution in 1.0.0-RC.3. Read more on Dynamic Binding in Ember.js Using Observers…

Handling JSON from the Command Line with Jq

In the battle of data formats, the two heavyweights are XML and JSON. Of late, JSON seems to be winning, in large part because most languages natively support JSON’s chosen data structures, but there’s one arena where JSON hasn’t made much of a showing: the command line. The command line provides a lot of programs to handle plain text (grep, cut, awk, and sed, to name just a few), and handling XML is even supported through xpath, but dealing with JSON has been the domain of standalone scripts written in Python, Ruby, or whatever your favorite language happens to be. There’s been few good ways to manage JSON directly from the shell. That’s why Stephen Dolan created Jq.
Read more on Handling JSON from the Command Line with Jq…

Conversing JSON with Qt and Ruby

I recently had a need to create a command processor in Qt, using C++ only, on a resource-limited system. I decided to use JSON rather than implement a fully-custom protocol.

Rather than pulling a 3rd party library into my Qt application, I ran across a handy overview from the QT Wiki demonstrating how to use QScriptEngine to do the parsing and validation. Unfortunately, QScriptEngine does not support serialization of data structures to JSON, although generating JSON using QString is pretty trivial.

Read more on Conversing JSON with Qt and Ruby…

Rails Routes in Javascript with js-routes

One thing that has annoyed me historically is hitting our Rails routes from Javascript. I’ve either sent the route down with other JSON data or simply typed the right string into the Javascript code. Both solutions work but I was never wild about them. Now we’ve been using the js-routes library for a couple of months and it’s been working great. It’s easy to use: access the documents resource with the Javascript function Routes.documents_path(). It takes parameters just like the Rails routes helpers.

Read more on Rails Routes in Javascript with js-routes…