Understanding key format: JSON

Time to dig into the actual code that makes up a key! First, let’s review the basics. You’ll remember this diagram of a customer key, which shows how keys and values relate:

KeyKeyValue
customerfirst_name Lee
last_name Leeson

And you know that, in order to tell Liquid to output the value “Lee,” you use the following notation:

Hi {{ customer.first_name }},

Now let’s look at a slightly more complex customer key:

KeyKeyValue
customerid f3bc06000001
created_at1621454609
dob1942-10-29T03:55:19.436507188Z
dob_clean857592281\n\nOct 29, 1942
emailLeeLeeson@example.com
first_nameLee
last_nameLeeson

Here’s the actual code that makes up that customer key:

{“id”=>”f3bc06000001”, “created_at”=>1621454609, “dob”=>”1942-10-29T03:55:19.436507188Z”, “dob_clean”=>”-857592281\n\nOct 29, 1942″, “email”=>”LeeLeeson@example.com”, “first_name”=>”Lee”, “last_name”=>”Leeson”}

That looks a bit different from the Liquid notation we’ve been learning—and that’s because the actual code for the key is formatted in JavaScript Object Notation, aka JSON. While we use Liquid notation to output key values, the keys themselves are formatted in JSON. 

**New terminology alert!**

We promised we’d call out any tricky vocab, and here’s a biggie: object. What we’re calling a key (in this example, it’s a key that is a collection of other keys) is called an object when we’re in JavaScript-land (e.g., the customer object): the whole bundle of names and their related values. Out in the wild, you’ll find that some documentation uses the terms key and object interchangeably. In this tutorial, we’re keeping it clear by saying key when we’re talking about Liquid notation and object when discussing JSON. 

While the terminology might get a little funky, at the end of the day, JSON is just the notation that Liquid uses to store key/value pairs—the data you keep about people, purchases, etc. The keys you use in Liquid reference specific JSON values