Photo by Ferenc Almasi on Unsplash

How to Coda with JSON — intro

What is JSON and when do you need it in Coda?

Christiaan Huizer
5 min readJul 29, 2022

--

When I started learning how to Coda I assumed that once I could work efficient with Filters and FormulaMap, Sequence and Buttons, I would be able to Coda decently. That is a valid assumption as long as you are not dealing with data that is generated outside your doc and you want to bring inside your doc. In this blog I explore the concept of JSON to make it easier for you to start working with packs & web hooks.

JSON becomes far more important than imagined when I started early 2020.

JSON

The abbreviation JSON stands for JavaScript Object Notation and this implies you work with JavaScript. JSON is a Data Representation Format, a syntax a set of rules that describe how data of all sorts relates. You need to understand how to notate it, how to write it, when you make use of it in the context of exchanging data between Coda and other software tools. These are the basics.

  • Strings — ‘Christiaan Huizer”,
  • Numbers — 10 1.5 -35
  • Boolean s— true false
  • null — null (stands for nothing)
  • Arrays — [1,1,2,3,5,8,13,21] [“Hello”, “Nathan”, “Louison”]
  • Objects {“Key” : “value”} {“age” : 50}

The last notation ‘Objects’ is the one we focus on most. It is a so called Key — Value pair and the value can be a string, a number, a boolean, a null or an Array

To create an object we need to use curly braces — { } — and inside we create the key — value pairs that make up our object. The Key must be surrounded by double quotes — “ “ — and followed by a colon — : — and then the value for that key and if we have multiple key — value pairs, we need a comma to separate every single one of our key — value pairs similarly as we create a List() in Coda.

In the example above you see that the string is surrounded by double quotes, while the number is not. If the value is a string, you always use the “ “ , that is why you sometimes notice the “” and sometimes they are left out like with “age”: (which is the key) that relates to the value 50 (a number). The booleans are written as true and as false, not as we do in Coda as True() or False() neither as a string with quotes, just plain true , false. This logic extends to the Array logic as well, if you create an Array filled out with strings you use the double quotes, but not in case of numbers or boolean values. An array starts with opening and closing square brackets — [] — . These square brackets you only see inside the Coda Formula Language when the name of your column has spaces like, see below. Or when you have lists inside lists. This comes close to how these brackets are used in JSON. A list is indeed like an Array.

the square brackets around a column name

You use the comma to separate the values you write and you use commas to indicate you are moving to a next value.

Nesting Arrays

So far we described mainly one to one relations, but in the real world the data complexity requires a bit more. We start with writing a simple JSON object, one we open and close with the curly brackets. This is called a flat format of data.

Simple JSON — a flat format of data

Once we put an object inside an object is looks different and you get into the power of JSON when show a hierarchy of data.

nested objects inside an array

In JSON the double quotes are an important element to remember and apply when dealing with strings and with Keys. In JavaScript it works a bit different, as it works different in Coda. In the latter the double quote logic we see for example in Format() that has the variables put in curly brackets surrounded by double quotes, followed by a comma, which is also used to seperate the arguments.

The format logic in Coda with curly brackets, double quotes and commas

This is the first blog about JSON and in next one we focus on how to Coda with JSON objects inside a Coda doc. The function ParseJson() plays a key role to work with data we get in via web hook. The data you bring inside your doc needs to be ‘unpacked’ to enable you to distribute values over columns to turn data into information.

I hope you enjoyed this article. If you have questions feel free to reach out. Though this article is for free, my work (including advice) won’t be, but there is always room for a chat to see what can be done. Besides you find my (for free) contributions to the Coda Community and on Twitter

My name is Christiaan and I support SMB with calculations (budgets and planning) and I prefer using Coda to get the job done.

Coda comes with a set of building blocksーlike pages for infinite depth, tables that talk to each other, and buttons that take action inside or outside your docーso anyone can make a doc as powerful as an app (source).

Not to forget: the Coda Community provides great insights for free once you add a sample doc.

Christiaan — ‘How to Coda with JSON — intro?”

--

--

Christiaan Huizer

I write about how to Coda . You find blogs for beginners and experienced makers. I publish about 1 / week. Welcome!