# JavaScript code runner for JSON transformations

**Use case:** 

Execute a JavaScript JSON transformation in a bounded sandbox and export structured stdout, status, timing, and errors.

## Input

```json
{
  "language": "javascript",
  "code": "const chunks=[]; for await (const c of process.stdin) chunks.push(c); const x=JSON.parse(Buffer.concat(chunks).toString()); console.log(JSON.stringify({total:x.values.reduce((a,b)=>a+b,0)}));",
  "stdin": {
    "values": [
      12,
      19,
      27
    ]
  },
  "parseJsonOutput": true,
  "timeoutSeconds": 5,
  "maxOutputBytes": 256000,
  "saveFiles": [],
  "maxSavedFileBytes": 5000000
}
```

## Output

```json
{
  "status": {
    "label": "Status",
    "format": "string"
  },
  "language": {
    "label": "Language",
    "format": "string"
  },
  "exitCode": {
    "label": "Exit code",
    "format": "integer"
  },
  "durationMs": {
    "label": "Duration (ms)",
    "format": "integer"
  },
  "timedOut": {
    "label": "Timed out",
    "format": "boolean"
  },
  "stdout": {
    "label": "Standard output",
    "format": "string"
  },
  "stderr": {
    "label": "Standard error",
    "format": "string"
  },
  "result": {
    "label": "Parsed result",
    "format": "object"
  },
  "files": {
    "label": "Saved files",
    "format": "array"
  },
  "executedAt": {
    "label": "Executed at",
    "format": "string"
  }
}
```

## About this Actor

This example demonstrates how to use [AI Code Runner Sandbox](https://apify.com/automation-lab/ai-code-runner-sandbox) with a specific input configuration. Visit the [Actor detail page](https://apify.com/automation-lab/ai-code-runner-sandbox) to learn more, explore other use cases, and run it yourself.