<p>What reasons might one prefer the <code>with_object</code> or the <code>with_array</code> options below?</p>

<pre><code>{
  "with_array": [
    {
      "name": "foo",
      "key": "value"
    },
    {
      "name": "bar",
      "key": "value"
    }
  ],
  "with_object": {
    "foo": {
      "key": "value"
    },
    "bar": {
      "key": "value"
    }
  }
}
</code></pre>

<p>Real world example: Why is the environment variable spec in this Kubernetes manifest using an array of <code>name</code> and <code>value</code> keys?</p>

<pre><code>pods/inject/envars.yaml 

apiVersion: v1
kind: Pod
metadata:
  name: envar-demo
  labels:
    purpose: demonstrate-envars
spec:
  containers:
  - name: envar-demo-container
    image: gcr.io/google-samples/node-hello:1.0
    env:
    - name: DEMO_GREETING
      value: "Hello from the environment"
    - name: DEMO_FAREWELL
      value: "Such a sweet sorrow"
</code></pre>

<p>From <a href="http://%20https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/#define-an-environment-variable-for-a-container" rel="nofollow noreferrer">Define an environment variable for a container</a></p>

jdb
<p>The answer to three questions can help finding which of the two is more appropriate:</p>

<p><a href="https://i.stack.imgur.com/V0ufB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/V0ufB.png" alt="questions to determine structure"></a></p>
