How do I deliver a nested JSON array for content reference with export view display? I created a product content type with content reference to article(one product to many articles). Then I added field "Content: ID" "Content: Title" and "(field_article: Content) Content: Title" to a new REST export View. "(field_article: Content) Content: Title" come from the relationship "Content referenced from field_article" I added in advanced.

The output is:

[
    {
        "nid":"3",
        "title":"Product1 title",
        "article_title":"Article1 title"
    },
    {
        "nid":"3",
        "title":"Product1 title",
        "article_title":"Article2 title"
    }
]


What I would like to achieve is something like this:

[
    {
        "nid":"3",
        "title":"Product1 title",
        "articles":
            [
                {
                    "title":"Article1 title"
                },
                {
                    "title":"Article2 title"
                }
            ]           
    }
]


How to implement this?

UPDATED:
I also tried aggregation, but in case of REST export View as the format is Serializer, no "group by" option in format setting but hal_json, json and xml options, while "Aggregation settings" appears on each filed. In this case, I don't know how to set "aggregation settings" group by node id. Also I cannot find document about aggregation settings of field in "Fields" section.
I've created a very simple module REST Export Nested to support nested JSON using Views Field Views.

After installing "REST Export Nested":


Install and enable <a
href="https://www.drupal.org/project/views_field_view" rel="nofollow noreferrer">Views Field
Views
Create view display of referenced content (Articles in your case) of type "REST export" or "REST export nested"
Add a relationship to the parent entity and contextual filter of parent entity ID
Create a view display of the parent entity of type "REST export
nested"
Add required fields (e.g. "nid", "title")
Add a field of type "Views field" (e.g. "articles"), configure with
the correct View and display and pass "nid" as the contextual filter


The module doesn't depend on Views Field View and may work with other fields which produce a JSON string.