# Returning null values in responses

**URL:** <https://discuss.jsonapi.org/t/returning-null-values-in-responses/1237>\
**Category:** Uncategorized\
**Created:** [March 15, 2018, 7:56am UTC](https://discuss.jsonapi.org/t/returning-null-values-in-responses/1237 "2018-03-15T07:56:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![marceloverdijk](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.jsonapi.org/marceloverdijk/32/521_2.png) [@marceloverdijk](https://discuss.jsonapi.org/u/marceloverdijk)\
**Post date:** [March 15, 2018, 7:56am UTC](https://discuss.jsonapi.org/t/returning-null-values-in-responses/1237/1 "2018-03-15T07:56:46Z")

</div>

I couldn’t find any statement or recommendation in the spec regarding `null` values in document responses.

E.g. take this example from the spec:

```
{
  "links": {
    "self": "http://example.com/articles/1/author"
  },
  "data": null
}

```

The `data` member is `null` here, which is required as the top level document must provide one of `data`, `errors` or `meta`.

When we look at the `attributes` the spec e.g. contains:

```
"attributes": {
  "title": "Rails is Omakase"
}

```

but what if the resource would contain a attribute with a `null` value?

I always like to explicitly return it like:

```
"attributes": {
  "title": "Rails is Omakase",
  "subtitle": null
}

```

It might be a arbitrary question but I wonder how others do this.

Note when e.g. returning a document without meta, links or jsonapi oject my preference is not to include them in the document:

```
{
  "data": [..] 
  "meta": null,
  "links": null,
  "jsonapi": null
}

```

So basically I prefer to only return `null` values for the `data` member (as it might be required) or for fields within the `attributes` member.
