# JSON List cannot contain an object

**URL:** <https://hub.mender.io/t/json-list-cannot-contain-an-object/1890>\
**Category:** General Discussions\
**Created:** [May 7, 2020, 2:46am UTC](https://hub.mender.io/t/json-list-cannot-contain-an-object/1890 "2020-05-07T02:46:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![purunaya](https://avatars.discourse-cdn.com/v4/letter/p/bc8723/32.png) [@purunaya](https://hub.mender.io/u/purunaya)\
**Post date:** [May 7, 2020, 2:46am UTC](https://hub.mender.io/t/json-list-cannot-contain-an-object/1890/1 "2020-05-07T02:46:31Z")

</div>

### mender-artifact will not allow JSON object within a list in the meta-data

I’m creating a custom update module. But ran into the restriction where the meta data file has a restriction "List cannot contain a JSON object.

The specific error I get both from the mender-artifact tool as well as the mender server UI when I try to upload the artifact is “Metadata: Invalid metadata section: compose: List cannot contain JSON object or list”. The “compose” key is an array of objects. That’s why this error is generated I guess. But I’m wondering why this restriction exists i.e. if I update the code to not have have the restriction what issues might I face?

It seems to be coming from this line of code.

```go
// Copies JSON structures, with the additional restriction that lists cannot
// contain any object or list.
func jsonDeepCopy(src interface{}) (interface{}, error)

```

Example use-cases:  
Creating a custom update module. We need to start/stop/update multiple services so was using an array objects where each object describes a service that we are updating.

### Specification

| Specification | |
| --- | --- |
| Module name | \< custom \> |
| Supports rollback | \< no \> |
| Requires reboot | \< no \> |
| Artifact generation script | \< yes\> |
| Full system updater | \< no \> |
| Source code | \< link \> |

---

<div class="post-metadata">

**Author:** ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)\
**Post date:** [May 7, 2020, 7:30am UTC](https://hub.mender.io/t/json-list-cannot-contain-an-object/1890/2 "2020-05-07T07:30:37Z")

</div>

It appears this restrictions was not documented, so I added it [here](https://github.com/mendersoftware/mender-artifact/pull/271).

The reason that the limitations exist is to facilitate the use of Augmented Artifacts, and specifically being able to filter JSON fields in a predictable way. See [“filtering header fields” in Augmented Artifacts](https://github.com/mendersoftware/mender/blob/master/Documentation/update-modules-v3-file-api.md#filtering-header-fields) for more information about it. It is still not implemented, but it is planned in future versions of Mender, so we have to keep the restrictions in place for now.

I have a couple of suggestions for you:

- If the list of keys in your object is small, and the same in every object, then I suggest splitting it across several lists, for example:

- If your structure is too advanced for that, or it is simply inconvenient, then I suggest instead to

---

<div class="post-metadata">

**Author:** ![purunaya](https://avatars.discourse-cdn.com/v4/letter/p/bc8723/32.png) [@purunaya](https://hub.mender.io/u/purunaya)\
**Post date:** [May 8, 2020, 9:30pm UTC](https://hub.mender.io/t/json-list-cannot-contain-an-object/1890/3 "2020-05-08T21:30:00Z")

</div>

Very good suggestion to just use a payload file. In metadata can just mention the payload file and pick that up. Thanks!
