Objects

Last updated: Mar 4th, 2018

Introduction

Cuneiform objects are a representation of data. The syntax for Cuneiform objects is very similar to that of JavaScript object notation syntax.

Object Syntax Rules

  • Data is in name/value pairs
  • Data is separated by commas
  • Curly brackets hold objects
  • Square brackets hold Arrays

Object Data - A Name and a Value

Cuneiform object data is written as name/value pairs. A name/value pair consists of a field name, followed by a colon, followed by a value:

name : "John"

Properties of Cuneiform Object Values

In Cuneiform, values must be one of the following data types.

  • a string
  • a number
  • another object
  • an array
  • null
{
    name : "John",
    age : 22,
    car : null
}                                   

Accessing Object Values

Object values can be accessed by using the square bracket ([]) notation.


var person = {
    name : "John",
    age : 22,
    car : null
};
var personName = person["name"];
                                    

Nested Objects

Values in a nested object can be another Cuneiform object.


var person = {
    name : "John",
    age : 22,
    cars : {
        car1 : "Ford",
        car2 : "BMW",
        car3 : "Nissan"
    }
};
                                    

Nested objects can be accessed by using the bracket notation.

var firstCar = person["cars"]["car1"];

What's next?

In the next section, we will discuss Arrays in Cuneiform.