# Source: https://content.nuxt.com/raw/docs/files/json.md

# JSON

> How to define, write and query JSON data.

## Define Collection

```ts [content.config.ts]
import { defineCollection, defineContentConfig } from '@nuxt/content'
import { z } from 'zod'

export default defineContentConfig({
  collections: {
    authors: defineCollection({
      type: 'data',
      source: 'authors/**.json',
      schema: z.object({
        name: z.string(),
        avatar: z.string(),
        url: z.string()
      })
    })
  }
})
```

## Create `.json` files

Create authors files in `content/authors/` directory.

<code-group>

```json [farnabaz.json]
{
  "name": "Ahad Birang",
  "avatar": "https://avatars.githubusercontent.com/u/2047945?v=4",
  "url": "https://github.com/farnabaz"
}
```

```json [larbish.json]
{
  "name": "Baptiste Leproux",
  "avatar": "https://avatars.githubusercontent.com/u/7290030?v=4",
  "url": "https://github.com/larbish"
}
```

</code-group>

<warning>

Each file in `data` collection should contain only one object, therefore having top level array in a JSON file will cause invalid result in query time.

</warning>

## Query Data

Now we can query authors:

```vue
<script lang="ts" setup>
// Find a single author
const { data: author } = await useAsyncData('larbish', () => {
  return queryCollection('authors')
    .where('stem', '=', 'authors/larbish')
    .first()
})

// Get all authors
const { data: authors } = await useAsyncData('authors', () => {
  return queryCollection('authors')
    .order('name', 'DESC')
    .all()
})
</script>
```