Advanced mapping

Hello,

I have some content I need to map into 1 string, I might be able to do it using an Iterator. But I think this must be also possible with 1 good formule. Can someone help me construct this formula?

So 2 things must be joined here:

  1. “value” items with nodetype “paragraph” must be joined with < br >
  2. Inside the paragraphs, ignore the “underline” and join everything to 1 string.

I already made a formula for #2, but I can’t get it to work with #1:

{{join(map(get(map(42.data.fields.description.content; "content"); 1); "value"); emptystring)}}

This is the content:

"content": [
            {
                "nodeType": "paragraph",
                "data": {},
                "content": [
                    {
                        "nodeType": "text",
                        "value": "Onze eerste dag in La Réunion: na wat supermarkt inkopen voor de komende dagen trekken we met onze huurwagens meteen de natuur in. ",
                        "marks": [],
                        "data": {}
                    }
                ]
            },
            {
                "nodeType": "paragraph",
                "data": {},
                "content": [
                    {
                        "nodeType": "text",
                        "value": "Onderweg naar %Hell-Bourg% -de toegangpoort van %Cirque de Mafate%-\npikken we een waterval (of 2) mee. In %",
                        "marks": [],
                        "data": {}
                    },
                    {
                        "nodeType": "text",
                        "value": "Hell Bourg",
                        "marks": [
                            {
                                "type": "underline"
                            }
                        ],
                        "data": {}
                    },
                    {
                        "nodeType": "text",
                        "value": "% maken we voor de eerste keer kennis met La Réunion in het gezellige verblijf %Le Be-Mahot%.",
                        "marks": [],
                        "data": {}
                    }```

Hey David,

if I understand you correctly - you want all of the “value” variables joined in a single string separated by < br > right?

This should work:

{{join(map(flatten(map(1.content; "content")); "value"); "<br>")}}
3 Likes

Great, thanks a lot!

2 Likes

Ohh my bad .. it’s not correct, there are 2 arrays, the arrays with “paragraph” need to be joined with < br >, the others just need to be concatenated (without < br >).