# Languages

### Overview

Laminar supports both JavaScript and JQ for writing flow transformations. Each language has its own strengths and use cases.

### JavaScript

JavaScript transformations use a simple function pattern:

```javascript
(payload) => {
  // Access data from previous steps or input
  const { input, step_1 } = payload;
  
  // Perform transformations
  const transformed = {
    // ... transformation logic
  };
  
  // Return result object
  return {
    "data": transformed,
    // Optional Laminar keywords
    "lam.httpRequest": {/*...*/}
  };
}
```

#### Advantages

* Familiar syntax for most developers
* Rich ecosystem of npm packages
* Native JSON handling
* Powerful array/object manipulation

#### Example Transformation

```javascript
(payload) => {
  const { step_1 } = payload;
  
  // Filter users who spent over $20
  const highValueUsers = step_1.data.users
    .filter(user => user.totalSpent > 20)
    .map(user => ({
      "lam.workflowId": 49,
      "lam.payload": {
        "lam.queryParams": {
          "email": user.email
        },
        "lam.body": user
      }
    }));

  return {
    "lam.result": highValueUsers
  };
}
```

### JQ

JQ is a lightweight, powerful language specifically designed for JSON processing:

```jq
# Access input data using dot notation
.input | 
# Transform using JQ operators
map(select(.totalSpent > 20)) |
# Output transformed data
{
  "lam.result": .
}
```

#### Advantages

* Concise syntax for JSON manipulation
* Powerful built-in functions
* Excellent performance for JSON processing
* Native streaming support

#### Example Transformation

```jq
.step_1.data.users |
map(
  select(.totalSpent > 20) |
  {
    "lam.workflowId": 49,
    "lam.payload": {
      "lam.queryParams": {
        "email": .email
      },
      "lam.body": .
    }
  }
)
```

### Choosing a Language

* Choose **JavaScript** when:
  * You need complex business logic
  * Your team is more familiar with JavaScript
  * You want to use npm packages
  * You need advanced string/array operations
* Choose **JQ** when:
  * You're primarily doing JSON transformation
  * You want concise, readable transformations
  * Performance is critical
  * You're working with streaming data


---

# Agent Instructions: 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:

```
GET https://docs.laminar.run/building-an-integration/languages.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
