You don't say what issues you're having so it is a little hard to help.
However, let's assume you're trying to get this JSON from Search G2 rather than from a publish JSON resource, and look at the basics.
You should be able to get a list of articles from G2 with JSON that looks like this in the "docs" field of the G2 response object:
GET https://searchg2.crownpeak.net/{collection}/select?q=*&fq=custom_s_type:article...
[
{
"id": "...",
"title": "...",
"custom_dt_publishedDate": "...",
"custom_ss_categories": [
"...",
"...",
"..."
],
"custom_s_articleImage": "...",
"custom_s_description": "..."
},
{
"id": "...",
"title": "...",
"custom_dt_publishedDate": "...",
"custom_ss_categories": [
"...",
"...",
"..."
],
"custom_s_articleImage": "...",
"custom_s_description": "..."
}
]
To get this into a format that matches your requirement, use Solr field aliases:
GET https://searchg2.crownpeak.net/{collection}/select?q=*&fq=custom_s_type:article&fl=heading:title,publishDate:custom_dt_publishDate,categories:custom_ss_categories,articleImage:custom_s_articleImage,description:custom_s_description...
[
{
"id": "...",
"heading": "...",
"publishedDate": "...",
"categories": [
"...",
"...",
"..."
],
"articleImage": "...",
"description": "..."
},
{
"id": "...",
"heading": "...",
"publishedDate": "...",
"categories": [
"...",
"...",
"..."
],
"articleImage": "...",
"description": "..."
}
]
Based on the JSON sample you provided, you will need to construct the JSON object with the top-level "title" and "articles" elements in your G2 response handling code.
The benefit of this approach is that the list of articles is dynamic and discovered/populated by query rather than having to fix the content at the point of publishing.