Allow defining an Item selector in Views REST exports

Created on 22 April 2023, almost 2 years ago

Problem/Motivation

When exporting data with REST in Views, it would be nice to be able to define an item selector (item_selector), since it is used in most Migrate examples, like this:

item_selector: product

From migrate_plus.migration.product.yml in Migrate Plus.

See for example How to parse JSON feed from a d8 into another d8 site using Feeds Migrate Module for someone else needing this.

Perhaps item_selector: 0 could function as a workaround?

Steps to reproduce

Create a REST export in Views, and see that there is no targetable item_selector:

[
  {
  "nid": [
  {
    "value": 14
  }],
[...]

See that most Migrate examples use an item_selector, and that it's present in the Migrate Plus example:

{
  "product": [
    {
      "upc": "11111",
      "name": "Widget",
      "description": "Helpful for many things.",
      "price": "14.99"
    },
[...]

https://git.drupalcode.org/project/migrate_plus/-/blob/6.0.x/migrate_jso...

Proposed resolution

Add an optional "Item Selector" field in REST export Views, maybe under Format > Settings?

Accepted request formats
[ ] json
[ ] xml
Request formats that will be allowed in responses. If none are selected all formats will be allowed.

Item Selector
[ Products ]
Will wrap the exported data with this value.

Remaining tasks

Decide if it's a good idea, and add the feature if we think it is.

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Active

Version

10.1

Component
REST 

Last updated 10 days ago

Created by

🇩🇰Denmark ressa Copenhagen

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

Comments & Activities

Production build 0.71.5 2024