Types of values

As we’ve discussed, keys and values come in pairs—the key points to the value (aka, the specific piece of data you have stored). 

Here are the simple types of values you’ll find in Liquid:

StringLetters, numerals, and special characters
NumberIntegers (numbers with no decimal point) and floats (numbers with a decimal point
BooleanTrue or false flag (not a string)

Strings are composed of letters, numbers, and special characters. They must be enclosed in double quotes in JSON. For example, the email address from our customer key in is a string. 

 “email”=>”LeeLeeson@example.com”

Numbers are integers (numbers with no decimal point) and floats (numbers with a decimal point). Here’s an example of a number from the customer key we looked at above:

“created_at”=>1621454609

Boolean values simply indicate whether a particular condition is true or false. For instance you might have a key called newsletter_signup, and the value would indicate whether or not a customer has signed up for your newsletter:

“newletter_signup”=>true

When a key has no value

In Liquid, a key points to a value—but sometimes your data store might be missing the value that a particular key is referencing, so there’s no value to output:

  • Nil: there is no value stored that corresponds to the key. This might happen if, say, a customer didn’t fill out their last name when they signed up for your newsletter. If you used the key {{ customer.last_name }} in that case, the value would be nil.  
  • EmptyDrop value will be returned if you try to use a key that’s been deleted. This doesn’t come up often.

These aren’t really types of values, in the sense that you’d never actually use a key to output them. Instead, think of them as potential circumstances that you can use a tag to account for, like back in Module 1 when we used a tag to output “Hi friend” if we didn’t have a value for our name key.