Add ArrayKeyValue Tamper plugin to handle associative array

Created on 1 September 2021, about 4 years ago
Updated 19 July 2025, 3 months ago

Issue/Requirement

Accept input of a nested array by a Feed and return values based on a given key.

This issue is based on ingesting a JSON endpoint as a source for a Drupal Feed, though it may be useful for other source formats as well. It is intended to handle a field that contains an associative array, or potentially a nested array with key=>value pairs of string or numeric values. For example:

JSON Data:

"categories":[{"title":"Category Title 0","id":1234}, {"title":"Category Title 1","id":2345}],

PHP Structure:

categories = [
  0[
    'title'=>'Category Title 0', 
    'id'=>'1234'
  ],
  1[
    'title'=>'Category Title 1',
    'id'=>'2345'
  ]
];

Proposed resolution

This involves creating a new plugin called "ArrayKeyValue" for the Tamper module, which is used by the Feeds Tamper module.
It will accept an associative array (single or multi-level) and recursively find keys that match the given key string from the plugin configuration settings. The values for these keys will be returned by the plugin as a flat indexed array.

Note: It may still be necessary to use other plugins (such as 'explode') to further modify the returned array so that it can be used by Drupal, depending on how the feed mapping is configured.

Related Issues:

https://www.drupal.org/project/tamper/issues/3018590 β†’
https://www.drupal.org/project/feeds/issues/2453123 β†’
https://www.drupal.org/project/feeds_tamper/issues/2978476 πŸ› Importing Taxonomy Not Provided As String Needs review

✨ Feature request
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States kbaringer

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024