# to-json-list

## Interface

```typescript
interface parser {
  name: "to-json-list";
  output:
    | {
        type: "file";
        filePath: string;
      }
    | { type: "JSON" };
  options?: {
    stringPathSeparator?: string;
  };
}

```

## Options

<table><thead><tr><th width="245">Parameter</th><th width="100">Required</th><th width="101">Type</th><th width="105">Default</th><th>Description</th></tr></thead><tbody><tr><td><code>stringPathSeparator</code></td><td><code>false</code></td><td><code>string</code></td><td><code>"."</code></td><td>Override the separator character used to build the string path property.</td></tr></tbody></table>

## Return type

The parser produces a custom data structure representing the flatten token tree.

```typescript
type FlattenNode = (
  | {
      kind: 'group';
    }
  | {
      kind: 'collection';
      modes: Array<string>;
    }
  | {
      kind: 'token';
      type: string;
      modeValues: Array<{
        mode: string;
        value: unknown;
      }>;
    }
) & {
  path: Array<string>;
  stringPath: string;
  name: string;
  description?: string;
  extensions?: unknown;
};

type ParserOutput = Array<FlattenNode>
```

## Basic usage

{% tabs %}
{% tab title="Input" %}
{% code lineNumbers="true" %}

```json
{
  "aCollection": {
    "$collection": {
      "$modes": ["light", "dark"]
    },
    "blue": {
      "$type": "color",
      "$value": {
        "light": {
          "model": "hex",
          "hex": "#0000CC",
          "alpha": 1
        },
        "dark": {
          "model": "hex",
          "hex": "#0000FF",
          "alpha": 1
        }
      }
    }
  },
  "aGroup": {
    "aDimension": {
      "$type": "dimension",
      "$value": {
        "default": {
          "unit": "px",
          "value": 16
        }
      }
    }
  }
}

```

{% endcode %}
{% endtab %}

{% tab title="Config" %}
{% code title=".specifyrc.json" lineNumbers="true" %}

```json
{
  "version": "2",
  "repository": "@organization/repository",
  // Only use the personalAccessToken when working with the CLI
  "personalAccessToken": "<your-personal-access-token>",
  "rules": [
    {
      "name": "To JSON",
      "parsers": [
        {
          "name": "to-json-list",
          "output": {
            "type": "file",
            "filePath": "tokens.json"
          }
        }
      ]
    }
  ]
}
```

{% endcode %}
{% endtab %}

{% tab title="Output" %}
{% code title="tokens.json" lineNumbers="true" %}

```json
[
  {
    "path": [
      "aCollection"
    ],
    "stringPath": "aCollection",
    "name": "aCollection",
    "kind": "collection",
    "modes": [
      "light",
      "dark"
    ]
  },
  {
    "path": [
      "aCollection",
      "blue"
    ],
    "stringPath": "aCollection.blue",
    "name": "blue",
    "kind": "token",
    "type": "color",
    "modeValues": [
      {
        "mode": "dark",
        "value": {
          "model": "hex",
          "hex": "#0000FF",
          "alpha": 1
        }
      },
      {
        "mode": "light",
        "value": {
          "model": "hex",
          "hex": "#0000CC",
          "alpha": 1
        }
      }
    ]
  },
  {
    "path": [
      "aGroup"
    ],
    "stringPath": "aGroup",
    "name": "aGroup",
    "kind": "group"
  },
  {
    "path": [
      "aGroup",
      "aDimension"
    ],
    "stringPath": "aGroup.aDimension",
    "name": "aDimension",
    "kind": "token",
    "type": "dimension",
    "modeValues": [
      {
        "mode": "default",
        "value": {
          "value": 16,
          "unit": "px"
        }
      }
    ]
  }
]
```

{% endcode %}
{% endtab %}
{% endtabs %}


---

# 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.specifyapp.com/reference/parsers/to-json-list.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.
