icon picker

Formula: ParseJSON()
Category: Miscellaneous

json-download (1).svg
Parses out a JSON string
or stated otherwise...
Hey Coda, I have a JSON string here, but I only need parts of it to accomplish what I need. Can you just give me the info I need?

ParseJSON() has two parameters.

ParseJSON(JsonString, Path)

A string of JSON text.

ParseJSON(JsonString, Path)

They key for the value to extract.
Don’t let this formula intimidate you - ParseJSON() is crucial for working with Codas Webhook Invoked automations. To understand how this formula works, though, you must first understand what JSON is.

What is JSON

JSON stands for JavaScript Object Notation and is simply a way of storing information. Put very simply, it contains information as key/value pairs within curly braces.
Let’s break that down 👇

Basic JSON structure

What are values?
Values in a JSON object always come second in a pair and are on the right-hand side of the :. Values are the information you actually want and are after.
For example, the JSON object below represents some information about a person. The valuable information is not necessarily that this person has a name (aka the key) but rather that that persons name happens to be Bob (aka the value within the key/value pair)
Group 1824.png

JSON with nested structure

A JSON object can also have nested properties. In the past example, we had a JSON object representing a person that contained information about that person.
Here is an example of a more complex JSON object that represents a person
Nested Array
Nested Array
Objects can also contain things called arrays which are similar to a simple list in Coda. The square brackets [ designate the end and beginning of an array and items within an array are separated by a ,.
Below, the Bob JSON object is storing the information that he has 3 children and their corresponding names.
Group 1827.png

Accessing Values in JSON

JSON is only useful to you in Coda when you can access the data you want. The Path parameter of ParseJSON() is the means by which you will access specific information in a JSON object.
But there are specific rules by which you can access JSON especially when it comes to nested objects. Let’s try it out below!

Accessing keys that with a simple non-nested value

In order to access objects that are not nested in any way and do not contain any arrays, simply type in the key as the Path parameter for your formula
{"name":"bob","age":"42","email":"","children_names":["Anna","Sophia","Willow"],"address":{"street":"444 Castro Way","city":"Mountain View","state":"CA"}}
There are no rows in this table

Accessing keys that are nested inside another object

Test is out below 👇
{"name":"bob","age":"42","email":"","children_names":["Anna","Sophia","Willow"],"address":{"street":"444 Castro Way","city":"Mountain View","state":"CA"}}
There are no rows in this table

Accessing values inside of an array

Try it for yourself below! 👇
{"name":"bob","age":"42","email":"","children_names":["Anna","Sophia","Willow"],"address":{"street":"444 Castro Way","city":"Mountain View","state":"CA"}}
There are no rows in this table

Why is This Important Again?

Coda has three types of automations you can trigger.
Without knowing how to use ParseJSON() webhook automations will be near useless
The third option (webhook) will almost always involve a JSON object being sent to your document.
For example, if you use as a payment processor for anything, you can cause any stripe activity to be sent directly to your Coda doc via a webhook.
But Stripe will send any and all data to you as a giant JSON object
In order to get access to that data inside of your Coda doc you will need to know how to unpack or access values within that object.
Expose and have access to the image URL of any uploaded image in Coda

Ready to master Coda yourself?

The Coda School doesn’t just teach you about formulas, but rather teaches you how to think about formulas and leverage them in ways that end up helping you build powerful workflows in your docs.
The Coda School also provides bi-weekly office hours where you can bring your docs for help! A $500 per month value you get for free as part of the school!

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
) instead.