> For the complete documentation index, see [llms.txt](https://osl.mistium.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://osl.mistium.com/arrays-and-objects/making-arrays-or-objects.md).

# Making Arrays Or Objects

If you want a json editor, I suggest [https://www.jsonblob.com](https://www.jsonblob.com/) or <https://jsoncrack.com/editor>

## Creating Arrays

Arrays in OSL are 1-indexed collections that can hold any type of value.

```javascript
// Simple array
numbers = [1, 2, 3, 4, 5]

// Array with expressions
base = 10
computed = [base * 1, base * 2, base * 3]  // [10, 20, 30]

// Mixed type array
mixed = [1, "text", true, {x: 10}]

// Array with computed values
vals = [1 + 1, "pre" ++ "fix", 10 * 2]  // [2, "prefix", 20]
// Note: ++ concatenates without spaces, so "pre" ++ "fix" becomes "prefix"
```

## Creating Objects

Objects are collections of key-value pairs that can include computed values and methods.

```javascript
// Simple object
person = {
    name: "John",
    age: 30
}

// Object with computed values
numbers = {
  num1: 0.5 * 2,
  num2: 1 * 2,
  num3: 1.5 * 2
}

// Object with methods
multiplier = 2
product = {
    price: 10,
    discount: 0.2,
    final: def() -> (
      return self.price * (1 - self.discount) * multiplier
   )
}

log product.final()
```

## Important Notes

* Arrays are 1-indexed (first element is at index 1)
* Objects can use `self` to reference their own properties
* Both arrays and objects can contain any OSL data type
* Values can be computed when creating arrays or objects
* Methods can be included in objects using `def() ->`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://osl.mistium.com/arrays-and-objects/making-arrays-or-objects.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
