Using JSON data in your designs in Sketch

anjhero
Design + Sketch
Published in
4 min readJun 24, 2016

This morning I woke up to a good news. Craft, an amazing Sketch plugin by InVision, now comes with a feature to import JSON data to your design. I was pretty blown away to see this update.

I’m personally happy with this update because I work a lot with data in my designs. I am not a fan of putting up dummy data in my designs. As a designer, you should know how your designs work after implementation. Most of the cases, your designs are bound to break if you haven’t used close-to-real data in your designs.

Here’s one example where I have to list organizations that are listed in IATI Registry. (To learn about IATI, see here.)

Our aim is to obtain this:

In the picture above, we have listed organization names (for example: ACTED, ADD International, etc.) and its id (for example: 1467e95f-54fe-4a09–9bae-65ae840742b5, 52145de3-d3dd-4447-bf66–77aa8fdf6506, etc.) below it.

Our traditional approach would be to put up dummy data and replace them later by manually copy-pasting one by one from another source.

With Craft’s Data feature, this is a piece of cake. Do make sure Craft plugin is installed for Sketch :)

Lets start by creating a new document in Sketch and move it into the following direction:

Everything is simple till now. I’ve also created placeholder texts for Organization’s name and organization’s id. These will be replaced by their real values in a while.

If you’ve installed Craft, you’d see this panel in Sketch:

Lets select “Organization Name” layer and click on the topmost item in the Craft panel.

Click on JSON.

Type a JSON url or if you have a local JSON file, drop it here. I’m using IATI Registry’s organization fetching file: http://iatiregistry.org/api/3/action/package_search?q=extras_filetype:organisation

Click on “Import”.

Go to the value you want to place in your design. For this example, I’m using result.results.0.organization.title field. Clicking on that field places the Organization’s Name into the design. Similarly, I place Organization’s id’s value by clicking on the result.results.0.organization.id field.

So far, we’ve collected the real data for one item. Now, this is where the magic happens. We can use Craft’s “Duplicate Content” feature to actually populate all the Organization Titles and IDs into the design.

Now all we have to do is select the layers that we want to duplicate (in this case, Organization Title and Organization ID) and click on “Duplicate Content”.

Click on Vertical checkbox. Add numeric count that you want to repeat for the duplication along with gutter width.

Click on “Duplicate Content” button and just watch the magic happen :)

Craft will pull data from the JSON file that you just used and populate them in the design.

And that’s it. I’ve added “Load more” button in the end to indicate load more functionality.

Here’s a silent video of the process:

This is quite an amazing update to the already-awesome plugin and is surely a big time saver.

What do you think of the plugin? Let me know in the comments.

--

--

anjhero
Design + Sketch

UX enthusiast (http://anjhero.me) (https://dribbble.com/anjhero), VP of Product Innovations and Co-founder at YoungInnovations