How can I programmatically add data to an address field? I'm trying to import user data from a json file. So far I managed to import most of the information, but now I'm stuck on the address field (created with Address module for Drupal 8).
In the json file (exported from a Drupal 7 website), there is city, country code and country name.
How can I import this data into the new field (the machine name is field_address)?
So far I tried using Drupal::entityTypeManager.
$values = array(
            'name' =&gt; $user[&quot;name&quot;],
            'pass' =&gt; '',
            'status' =&gt; $user[&quot;status&quot;],
            'mail' =&gt; $user[&quot;e_mail&quot;],
            'field_first_name' =&gt; $user[&quot;first_name&quot;],
            'field_last_name' =&gt; $user[&quot;last_name&quot;],
            'field_address' =&gt; $city,
        );

        $userStorage = \Drupal::entityTypeManager()-&gt;getStorage('user');
        $userEntity = $userStorage-&gt;create($values);

It doesn't work: The address field stays empty.
Should I use the sub fields?
If you have a field with multiple properties then use an extra array:
$values = [
  'name' =&gt; $user[&quot;name&quot;],
  'pass' =&gt; '',
  'status' =&gt; $user[&quot;status&quot;],
  'mail' =&gt; $user[&quot;e_mail&quot;],

  'field_address' =&gt; [
    'first_name' =&gt; $user[&quot;first_name&quot;],
    'last_name' =&gt; $user[&quot;last_name&quot;],
    'city' =&gt; $city,
  ],
];