Test

Here is the use case  Name1 is the section names value1 is the text value,when next section name starts with item2 before empty section names consider as section names with the text followed by as mentioned  in the output 

a!localVariables(
  local!testdata: {
    { "Name1": "Item1", "Value1": "Data for Item 1" },
    { "Name1": null, "Value1": "Different data for Item 2" },
    { "Name1": null, "Value1": "Some other kind of data" },
    { "Name1": "Item2", "Value1": "Another example of data" },
    { "Name1": null, "Value1": "Random data like GBP 50,000" },
    { "Name1": "Item3", "Value1": "Data related to an event or value" },
    { "Name1": null, "Value1": "Adjustable by percentage of revenue" },
    { "Name1": null, "Value1": "Premium payable quarterly" }
  },
  
  local!testdata


expected output is 

[
{ "section": "Item1", "fullText": "Data for Item 1 Different data for Item 2 Some other kind of data" },
{ "section": "Item2", "fullText": "Another example of data Random data like GBP 50,000" },
{ "section": "Item3", "fullText": "Data related to an event or value Adjustable by percentage of revenue Premium payable quarterly" }
]

@Stefan Helzle      

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    If the other answers don't get you what you're looking for you could always change the way you define local!testData to be a list of map like below.

    local!testData: {
      a!map(
        section: "Item 1", 
        fullText: {
          "Data for Item 1",
          "Different data for Item 2",
          "Some other kind of data"
        }
      ),
      a!map(
        section: "Item 2", 
        fullText: {
          "Another example of data",
          "Random data like GBP 50,000"
        }
      ),
      a!map(
        section: "Item 3", 
        fullText: {
          "Data related to an event or value",
          "Adjustable by percentage of revenue",
          "Premium payable quarterly"
        }
      )
    }

Reply
  • 0
    Certified Senior Developer

    If the other answers don't get you what you're looking for you could always change the way you define local!testData to be a list of map like below.

    local!testData: {
      a!map(
        section: "Item 1", 
        fullText: {
          "Data for Item 1",
          "Different data for Item 2",
          "Some other kind of data"
        }
      ),
      a!map(
        section: "Item 2", 
        fullText: {
          "Another example of data",
          "Random data like GBP 50,000"
        }
      ),
      a!map(
        section: "Item 3", 
        fullText: {
          "Data related to an event or value",
          "Adjustable by percentage of revenue",
          "Premium payable quarterly"
        }
      )
    }

Children
No Data